0

Below I'm trying to get a query make is a json object, so that in my template using jQuery I can loop over it.

My View

from django.core import serializers
objectQuerySet = Recipient.objects.filter(incentiveid=incentive).values("mobile", "countryid")
data = serializers.serialize("json", objectQuerySet)

return render_to_response('smssend.html', context_instance=RequestContext(request))

I'm getting the following error.

Non-model object (<type 'dict'>) encountered during serialization

Request Method: 

why?

1 Answer 1

2

#values() "returns dictionaries when used as an iterable" - https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.values

I think you need python's json#dumps(dict) here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.