How convert list to queryset?

31 views
Skip to first unread message

이규남

unread,
May 19, 2019, 9:22:01 PM5/19/19
to Django REST framework
I want to convert the model object list into queryset.
That is impossible?

I want to read the json file and change it to model and convert this model list to queryset to resender.
can you help me!

Chetan Ganji

unread,
May 19, 2019, 9:32:25 PM5/19/19
to django-res...@googlegroups.com
This one seems to be a small part of the solution. 


 
Regards,
Chetan Ganji
+91-900-483-4183


I’m protected online with Avast Free Antivirus. Get it here — it’s free forever.

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/5d2e05f9-bf74-426c-9dd8-923e90347fe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

이규남

unread,
May 19, 2019, 10:42:30 PM5/19/19
to django-res...@googlegroups.com
Thank you.
By the way, I have already completed the model change in json.
I just want to change the model to queryset.
You have to use queryset when rendering to receive all the posts.  

2019년 5월 20일 (월) 오전 10:32, Chetan Ganji <ganji....@gmail.com>님이 작성:

이규남

unread,
May 19, 2019, 10:42:47 PM5/19/19
to Django REST framework

Chetan Ganji

unread,
May 20, 2019, 5:21:52 AM5/20/19
to django-res...@googlegroups.com
Have you tried iterating over a list in the template YET??
If not, do it now and see the results :) 

If you really need a queryset only, below answer from below post will get it done.
"Ok...this post is now old BUT what you could do is get all the ids of the objects in your list, then perform a model.objects.filter(pk__in=list_of_ids)"

Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages