I want order the table A by a field in table B
class A(models.Model):
field1 = models.CharField()
class B(models.Model):
field1 = models.CharField()
field_fk = models.ForeignKey(A)
The table A don't has fk to B, but B has a fk to A. I want to do
anything like this:
query = A.objects.all().order_by('B.field1')
OR
query = A.objects.all().filter(B__field1__contains='word')
I try with select_related() but this not work too.
In sql I can do this with "left join", but I don't know how to do
this(ordering, join or search) in Django.
Any help?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---