i am selecting last object from my table using following Code
data= MyModel.objects.last()
This is Displaying object. i want to display full array of 'data' object.for that i am using Following Code
data= MyModel.objects.last().values()
However its not Working.How to do that?
You should swap .values(…) [Django-doc] and .last() [Django-doc], since before the .last(), you are working with a Manager or QuerySet, after .last() you are working with a MyModel object:
data= MyModel.objects.values().last()
That being said, using .values() is often not a good idea. It erodes the logic layer a model provides. Only in specific cases, like a GROUP BY on a certain value it is a good idea to use .values().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With