hello
i want to use ajax in my django project.
i have no problem with writing ajax method or url. my problem is in my django view.
i send a pk from template with ajax and in my view:
can anybody tell me if this is a good way to work with JsonResponse?
when i write this i get this error:
MyModel object is not iterable
what i have to do to solve this error.
every search that i make is about SimpleJson but i now SimpleJson is before django 1.7
i am working with django 1.11
can anybody save me from this
thanks
-- i want to use ajax in my django project.
i have no problem with writing ajax method or url. my problem is in my django view.
i send a pk from template with ajax and in my view:
def edit(request):
pk = request.GET.get('pk' or None)
instance = models.MyModel.objects.get(pk=pk)
return JsonResponse(instance)
can anybody tell me if this is a good way to work with JsonResponse?
when i write this i get this error:
MyModel object is not iterable
what i have to do to solve this error.
every search that i make is about SimpleJson but i now SimpleJson is before django 1.7
i am working with django 1.11
can anybody save me from this
thanks
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+unsubscribe@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/4efc338d-7326-4c98-9e03-c88ba0834ff3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment