Let's say your model looks like the following: class Standard(models.Model):
class Product(models.Model): has_standard = models.ManyToManyField(Standard, through="ProductStandard") class ProductStandard(models.Model): standard = models.ForeignKey(Standard) product = models.ForeignKey(Product) then you can get all products that have relation with specific standard by: Product.objects.filter(has_standard='specific_standard_id') Hope it helps. wy On Tue, Feb 2, 2010 at 2:50 PM, Eugene Mirotin <emiro...@gmail.com> wrote: > I have 3 models - Standard, Product, and ProductStandard. > > Standards represents some standardization document. > Product represents some product. > ProductStandard is the intermediary table having 2 FKs (Standard and > Product) as well as some extra fields (like comments about the > Standard for the specific Product - it's not important, I just try to > explain why we need this table). > > So, we have the m2m relation trough the intermediary table. > > We can use GET parameters for filtering in the products list, like > /?title="product_title"&company__foundation_date__lte="2009-12-01" > > I need the query of such type for the following filter: > "Get all the products that have the relation with the specific > standard", which means: > "There's record in the product.productstandard_set, where > standard=='specific_standard_id'" > > Is it possible? > > Thanks in advance! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.