So, my models:
UserProfile(models.Model):
user = models.OneToOneField(User)
company = models.ForeignKey(Company)
Company(models.Model):
...some fields...
Product(models.Model):
...some fields...
ProductLicence(models.Model):
product = models.ForeignKey(Product)
company = models.ForeignKey(Company)
News(models.Model):
related_products = models.ManyToManyField(Product)
And my query:
news =
News.objects.filter(related_products__productlicence__in=user.get_profile().company.productlicence_set.all()).distinct()
I hope that it will be useful to somebody.
Regards,
Gontran
On 29 mar, 10:34, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> On Tue, 2011-03-29 at 01:17 -0700, bruno desthuilliers wrote:
> > On 29 mar, 09:33, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> > > Product is not linked to them - they are linked to Product.
>
> > Sorry but I dont see the point here - you can follow a relationship
> > both way.
>
> pointless nitpick - apologies
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment