Thursday, June 23, 2011

Inconsistent keyword filtering on FK

I'm getting a 'cannot resolve keyword' on a objects.filter that
doesn't seem to make sense.

Here is the model:

class Person(models.Model):
payee = models.ForeignKey(
Payee,
null=True,
blank=True,
)
ut = models.ForeignKey(
Utility,
null=True,
blank=True,
)

The problem:

Utility.objects.filter(person=1144) # works fine
Payee.objects.filter(person=26) # gives us FieldError: Cannot resolve
keyword 'person' into field

I've tried to follow this around, finding myself in the Options object
where I printed out self._related_objects_cache.items() ... Utility
has about 20 other models that define a FK to it, and appear in the
related objects cache. Payee has about 13 models that define a FK to
it - but only one of them appears in the related object cache (and
it's not 'person')

I haven't been able to track it beyond this point to anything
conclusive. Any suggestions on where to look next?

using: django 1.3 (had same issue in 1.1 before migrating), postgres
8.4 / psycopg2

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