Because {{{QuerySet}}} has a serialize method included in Django, why
don't use it in {{{DjangoJSONEncoder}}}?
--
Ticket URL: <https://code.djangoproject.com/ticket/28208>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Tim Graham):
Can you explain what you're trying to do? As far as I see, `QuerySet`
doesn't have a `serialize()` method.
--
Ticket URL: <https://code.djangoproject.com/ticket/28208#comment:1>
Comment (by AbrahamGo8):
Replying to [comment:1 Tim Graham]:
> Can you explain what you're trying to do? As far as I see, `QuerySet`
doesn't have a `serialize()` method.
Django provides us {{{django.core.serializers.serialize}}} function to
serialize a {{{QuerySet}}}.
I want to create a wrapper about {{{DjangoJSONEncoder}}} to include
{{{QuerySet}}} ({{{DjangoCustomJSONEncoder}}} for example) serialization
but it comes to mind if Django gives us a function to serialize a
{{{QuerySet}}} why Django does not include it into
{{{DjangoJSONEncoder}}}? So I think that there must be a major issue to
not include it.
Regards
--
Ticket URL: <https://code.djangoproject.com/ticket/28208#comment:2>
Comment (by Tim Graham):
Can you elaborate on the use case for creating a wrapper around
`DjangoJSONEncoder` to include `QuerySet`?
--
Ticket URL: <https://code.djangoproject.com/ticket/28208#comment:3>
Comment (by Abraham González Ramírez):
Replying to [comment:3 Tim Graham]:
> Can you elaborate on the use case for creating a wrapper around
`DjangoJSONEncoder` to include `QuerySet`?
We are using a Front-end framework that need to receive a JSON for
rendering a collection. So we need to include a {{{Queryset}} into a
wrapper of {{{DjangoJSONEncoder}}} to be able to serialize {{{QuerySet}}}
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/28208#comment:4>
* status: new => closed
* resolution: => wontfix
Comment:
You might consider third-party packages such as [http://www.django-rest-
framework.org/ django REST framework] rather than building your own
serialization. I think queryset serialization is too nuanced (for example,
which fields should be serialized?) to add it to `DjangoJSONEncoder` which
serializes basic data types.
--
Ticket URL: <https://code.djangoproject.com/ticket/28208#comment:5>