tags:

views:

23

answers:

2
    class Publication(models.Model):
        title = models.CharField(max_length=30)


    class Article(models.Model):
        headline = models.CharField(max_length=100)
        publications = models.ManyToManyField(Publication)


A1=>[P1,P2]
A2=>[P2,P3,P4]

How to get a queryset in all of the [P1,P2,P3,P4] Article.all().publications.all() or Article.publications.all() !?

A: 

Publication.objects.all() will return you all publications. But what's the point?

dmitko
A: 

Your question isn't very clear. Are you looking to get all Publications that have at least one Article? If so:

Publication.objects.exclude(article=None)
Daniel Roseman
I want not all publications,Only be used to the Articles。
Sorry, I still don't understand.
Daniel Roseman