On Tue, 2006-08-15 at 20:38 -0700, [EMAIL PROTECTED] wrote:
> I have an existing mysql db. I reverse engineered the models.py with
> inspectdb...
> 
> My foreign key names seem to be messing up the query that django
> generates:
> 
> OperationalError at /admin/ghsite/inventory/
>   (1054, "Unknown column 'inventory.keyfgallid_id' in 'field list'")
[...]
> How can I fix this without renaming all of the keys?

It sounds like the foreign key columns in your database table are not
labelled the way Django naturally tries to work.

So, you need to specify the db_column attribute for the ForeignKey
models so that Django uses the right column name when you talk to the
database. You have complete flexibility about what the database tables
and columns are called in Django, so don't worry about needing to change
the db columns.

Normally (i.e. if you went from models to database tables, instead of
the other way around), the column for a 'keyfgallid' attribute that is a
ForeignKey will be the attribute name with _id appended, so
"keygfallid_id".

Best wishes,
Malcolm


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