def edit(request):
pk = request.GET.get('pk' or None)
instance = models.MyModel.objects.get(pk=pk)
return JsonResponse(instance)
You may want to take a look at http://www.django-rest-framework.org/
The error tells you exactly what's wrong: MyModel object is a Model, which is not iterable. You want to serialize the MyModel object, which is possible with Django Rest Framework.
I usually advise against using JsonResponse over DRF. You should only use it if you're using it once or twice in your app and it's not related to a model or something that's complex.
--
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...@googlegroups.com.
To post to this group, send email to django...@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/4efc338d-7326-4c98-9e03-c88ba0834ff3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.