On Thu, Jun 23, 2011 at 2:21 PM, Cal Leeming [Simplicity Media Ltd] <
[email protected]> wrote:
> The problem:
>>
>> Utility.objects.filter(person=1144) # works fine
>> Payee.objects.filter(person=26) # gives us FieldError: Cannot resolve
>> keyword 'person' into field
>>
>
> Is this what you need??
>
> Payee.objects.filter(
> person = Person(id=26)
> )
>
> or.. Payee.objects.filter(
> person__id = 26
> ) - but this would be slightly more performance hitting i think.
>
or just
Payee.objects.filter(person_id=26)
person__id is a field lookup on the person model, so (in theory) Django will
contruct the SQL join, and test the person.id column. person_id is a column
in the payee table, and Django will construct SQL which compares against
that.
I don't know if there's any practical difference in performance -- I would
hope that any decent SQL query optimizer should be able to change
select payee.* from payee join person on (payee.person_id = person.id) where
person.id = 26
into
select payee.* from payee where person_id = 26
--
Regards,
Ian Clelland
<[email protected]>
--
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.