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. Too much automagic or what? In case you wondered: inspectdb croaks on this monster so the models are all hand-made. So, new question: how do I prevent the python-attribute in the Org-class from being renamed in the sql? Now, if I had made the underlying sql I would never have called every primary key the same though, because if you don't, you get to use natural joins, which rocks when it comes to readability/maintenance of sql... but that's just me. HM --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

