Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible ValuesQuerySet iteration issue #33

Open
GertBurger opened this issue Oct 22, 2018 · 0 comments
Open

Possible ValuesQuerySet iteration issue #33

GertBurger opened this issue Oct 22, 2018 · 0 comments

Comments

@GertBurger
Copy link

Hi

I noticed one of our endpoints breaks when outputting as xml but works fine when using the DRF json renderer.

It outputs something like this:

<root> *a long string ending in* , '...(remaining elements truncated)...']</root>

With an endpoint similar to this:

@api_view()
def myendpoint(request):
    return Response(MyModel.objects.values('field1', 'field2'))

Wrapping the ValuesQuerySet in a list() call fixes the problem.

The DRF docs mention that Response() objects should only be given Python primitives so I understand that this specific usage may not (and possibly should not) be supported.

It is however unexpected that the behaviour differs from DRF's standard JSON renderer which iterates correctly over ValuesQuerySets.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant