Oh, thanks. Ok, I just tried taking that out (so model now says "staff_id = models.ForeignKey(User)"), but that gave this error: OperationalError: (1054, "Unknown column 'restaurant.staff_id_id' in 'field list'")
? On Thu, Sep 11, 2008 at 4:09 PM, Malcolm Tredinnick < [EMAIL PROTECTED]> wrote: > > > On Thu, 2008-09-11 at 16:01 -0500, Chris Stromberger wrote: > > I would like to include a foreign key in a table that links to a user > > in Django's auth_user table. Or maybe this is a dumb idea--if so, > > interested in hearing why. > > > > > > So the table ("restaurant") with the foreign key includes (mysql): > > > > > > staff_id int(11) NOT NULL, > > foreign key(staff_id) references auth_user(id) on delete no action on > > update cascade, > > > > > > > > If I include this in my model: > > > > > > > > from django.contrib.auth.models import User > > > > staff_id = models.ForeignKey(User, db_column = 'id') > > This probably isn't what you inteded to write. The db_column attribute > specifies what the name of the database column in *this* table will be > called. The name of the column in the table it refers to is worked out > automatically (since it's almost always the primary key of that table > and for other cases, Django has the to_field attribute). > > Regards, > 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?hl=en -~----------~----~----~----~------~----~------~--~---