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')

it seems to screw things up.  If I start a python shell, import my model,
then run Restaurant.objects.all(), I get

OperationalError: (1054, "Unknown column 'restaurant.id' in 'field list'")

Not sure what is going on.  The model has an explicit primary key defined
(this is a legacy db):

  restaurant_id = models.AutoField(primary_key = True)

Thanks for any help,
Chris

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

Reply via email to