Hi Bruno,

yes you're right. I should change my model in the way you mentioned
it. I saw that a couple of minutes ago.

And to answer to my initial question, I might have found the answer.
The query would be:

news = News.objects.filter(related_products__productlicence__in =
user.get_profile().company.product_licences.all()).distinct()

On 29 mar, 10:24, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
> On 29 mar, 09:11, gontran <geoffroydecorb...@gmail.com> wrote:
>
> > Hi everybody,
>
> > considering the folowing models:
>
> > UserProfile(models.Model):
> >     user = models.OneToOneField(User)
> >     company = models.ForeignKey(Company)
>
> > Company(models.Model):
> >     product_licences = models.manyToManyField(ProductLicence)
>
> Sorry if I missed something, but are you sure you want a m2m
> relationship here ??? This means that a same licence can "belong" to
> many companies, which seems rather weird to me. As far as I'm
> concerned I'd make "company" a foreign key in ProductLicence - or I
> just don't understand your definition of what "licence" is ???
>
> > Product(models.Model):
> >     ...some fields...
>
> > ProductLicence(models.Model):
> >     product = models.ForeignKey(Product)
>
> (snip)

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to