I want to know if we can pass a list of objects (in this case list of blog 
objects to the Entry model as the manytomany object parameter). On doing so 
i am not getting the desired result. Please help.

models.py

class Blog(models.Model):
    id=models.AutoField(primary_key=True)
class Entry(models.Model):
    id=models.AutoField(primary_key=True)
    blogs=models.ManyToManyField(Blog)

views.py

def something(request):
    list=[]
    for i in range(10):
        list.append(Blog.objects.get(pk=i))
    ans=Entry.objects.filter(blogs=list)
    print(ans)
    #some other work.

-- 
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+unsubscr...@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/87b878aa-da70-454f-98fb-035d1222c266%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to