Hi, i want to rendering JSON from Django views, here is my models: class Continent(models.Model): name = models.CharField(max_length='10',unique=True) code = models.CharField(max_length='5',unique=True) class Country(models.Model): name = models.CharField(max_length='10',unique=True) code=models.CharField(max_length='10',unique=True) continent=models.ForeignKey('Continent') ###############here is my views.py####################### from django.http import Http404 from django.shortcuts import render_to_response, get_object_or_404 from django.utils import simplejson as json from models import Continent, Country
def continent_json(request, continent_code): continent=get_object_or_404(Continent, code=continent_code) if not continent: raise Http404("Not implemented") context = {"all_contries": Country.objects.filter(continent=continent.id)} data=json.dumps(context) return render_to_response(data, mimetype="application/json") I want to get the result when the continent_code=eu: { "xk": "Kosovo", "ch": "Switzerland", "gr": "Greece", "va": "Vatican City", "ee": "Estonia", "is": "Iceland", "al": "Albania", "gg": "Guernsey", } There is some problems with my views.py file. Anybody know how to modify my views.py? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.