country = request.POST['country']
country = get_object_or_404(Country, country=country)


On Tuesday, January 5, 2016 at 6:02:28 PM UTC+5:30, sonu kumar wrote:
>
> Models
>
> class Country(models.Model):
>     country = CountryField()
>
> class City(models.Model):
>     name = models.CharField(max_length=1000)
>     country = models.ForeignKey(Country)
>
> cities = serializers.serialize("json", country.city_set.all(), 
> fields=('name', 'id'))
>
>
> In this 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}]. 
>
>
> How to fix this error?
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1429ec4c-e3c3-4160-963f-a747d3381909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to