I'll be happy to. I did put in a track item for this (although I can't remember what the number is).

I'm using PostgreSQL 8.1


This is actually a combination of two related errors: One that leads to a searching error (?e=1) and another that leads to a ProgrammingError (identified in the track item)

Here is the scenario:
1. Foreign Key in the ordering
2. Foreign Key is not a typical "id" key (using primary_key=True) (I'm assuming this, BTW)

If the Foreign key IS IN the search_fields, everything will return and you will see a ?e=1 in the query string of the results.
If the Foreign key IS NOT IN the search_fields, you will get a ProgrammingError, missing FROM-clause (the foreign key is used in the ORDER BY clause but is not JOINed)

In my models, the Address model is the problem. The ZIP_Code model is used as the primary ordering field. Really, I just need the zipcode number, but it obviously references the entire object.

I had this exact same problem with my Route model, when I used the ZIP_Code model in the ordering and search_fields. I was able to get around it because the primary key is a concatenation of zipcode-carrier route.

I hope I've given you enough information, and I really hope I just made a silly mistake somewhere. :)

Thanks for the attention,

Corey

On Aug 11, 2006, at 11:01 AM, Adrian Holovaty wrote:


On 8/10/06, Corey <[EMAIL PROTECTED]> wrote:
I have a model with several foreign keys. Currently when I do a search,
it returns everything. The query string shows ?e=1.

The search_fields is set to a local field and a foreign key.

If a remove the foreign key from the search fields, I get a programming
error: FROM-clause is missing, relating to the foreign key I just
removed from the search_fields. This same foreign key is in the
ordering list.

Hey Corey,

That's really strange...Would you be willing to paste your model, so
we can try to recreate the error? Also, which database backend are you
on?

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to