[Fixed]-Tastypie queryset values is not being displayed

1👍

The values() method returns a queryset that returns dictionaries instead of model instances. A model instance has a pk attribute but the dictionary does not. Tastypie is trying to access pk in the dict, thus giving the error. You need to use a method that returns a queryset giving model instances.

From Django’s documentation use values():

when you know you’re only going to need values from a small number of the available fields and you won’t need the functionality of a model instance object.

In your case, you do need the functionality of model instance object, pk attribute.

I’d suggest using Question.objects.all()

Leave a comment