Can a ForeignKey be a primary key? I'm getting the following error.

Here is the relevant part of the model:

class UserProfile(models.Model):
    user = models.ForeignKey(User, primary_key=True,
edit_inline=models.STACKED, num_in_admin=1,min_num_in_admin=1,
max_num_in_admin=1,num_extra_on_change=0)
    ...

$ python manage.py sql profiles
calling execute_manager
BEGIN;
Traceback (most recent call last):
  File "manage.py", line 12, in ?
    execute_manager(settings)
  File
"/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
line 1319, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File
"/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
line 1286, in execute_from_command_line
    output = action_mapping[action](mod)
  File
"/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
line 115, in get_sql_create
    final_output.extend(_get_many_to_many_sql_for_model(model))
  File
"/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
line 233, in _get_many_to_many_sql_for_model
    table_output.append('    %s %s %s %s (%s),' % \
KeyError: 'ForeignKey'


If I remove primary_key=True, then it happily produces the SQL (with
the default primary key 'id').


Grant


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