hello,

i'm struggling with ManyToMany fields (Rajesh helped me a lot;) and
have another question. My model Article, has ManyToMany relation with
Video model (for storing only youtube videos).

class Article(models.Model):
    video = models.ManyToManyField(Video, blank=True, null=True)

class Video(models.Model):
    url = models.CharField(max_length=300)
    name = models.CharField(max_length=300)

Then i add 3 videos to an Article. Since not all articles have videos,
i want to filter out those that have it.
Filter looks like this:

Article.objects.filter(video__isnull=False)

So here is the problem.. let's say i have 5 articles in my DB and only
one has 3 videos.. this filter doesn't return an article that has
videos, but rather returns 3x the same article name.. probably,
because of 3 added videos to it.
so my question here is: is this the right way to check, if article has
videos (Article.objects.filter(video__isnull=False))? if this the
right way, what is (should i add costum method in my model)?

I would appreciate any help,

Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to