On Tue, 2008-02-12 at 14:51 +0100, Hanne Moa wrote: > On Feb 12, 2008 2:23 PM, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Tue, 2008-02-12 at 14:13 +0100, Hanne Moa wrote: > > > 1. how do I get "Region: 'someregion (somelocation)'" in the admin > > > interface instead of "Region: '---------'"? > > > > I don't know why this is happening. ForeignKeys normally just work > > properly. It should be working as you expect. > > > > [..] So there's something slightly amiss with > > the way things are matched up in your retrofitted models. You could also > > try comparing the output of "manage.py sql <app_name>" to the actual > > database tables to make sure the reference is pointing to the right > > field, etc. > > I checked the generated sql. No wonder it went wrong. With db_column > in the ForeignKey, the attribute Org.region in python became org.id in > the sql, meaning there were several fields "id" in the same table! > When I removed db_column in ForeignKey, the Python attribute > Org.region became org.region_id in the table and hence not matching > the existing table.
Use db_column="region". Cheers, Malcolm -- Quantum mechanics: the dreams stuff is made of. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

