#26256: JSON serializer is not working for subset of fields.
--------------------------------------+--------------------
Reporter: sonus21 | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Serialization) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
{{{
class Country(models.Model):
country = CountryField()
class City(models.Model):
name = models.CharField(max_length=1000)
country = models.ForeignKey(Country)
country = request.POST['country']
country = get_object_or_404(Country, country=country)
cities = serializers.serialize("json", country.city_set.all(),
fields=('name', 'id'))
}}}
[https://docs.djangoproject.com/en/1.8/topics/serialization/#s-subset-of-
fields]
According to above code snippet and document it should return JSON object
with only name and id field but it returns
{{{
[{"fields": {"name": "Chennai"}, "model": "job.city", "pk": 1}]
}}}
instead of
{{{
[{"name": "Chennai", "id": 1}]
}}}
which includes all fields of a model City.
--
Ticket URL: <https://code.djangoproject.com/ticket/26256>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.c7aacb93aaf7f36256b0ee13402e85df%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.