On Fri, Feb 11, 2011 at 5:20 PM, josch <joschw...@web.de> wrote:
> Hi,
>
> I`m searching for a solution for the following problem:
>
> I have, for example, those two classes:
>
> class Order(self):
>        type = models.CharField(1)
>
> class OrderPositions(self):
>        order = ForeignKey(Order)
>
>
> Now I want to get every Order Position, whoose order has the type, for
> example 'A'.
>
> queryset = OrderPositions.objects.filter(order.type='A')
>
> Of course this does not work, I just wanted to make clear what I want
> to to.
>
> What is the best way to handle a demand like this.
>
> Thank you!
>

http://docs.djangoproject.com/en/1.2/topics/db/queries/#lookups-that-span-relationships

queryset = OrderPositions.objects.filter(order__type='A')

Cheers

Tom

-- 
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