Monday, June 28, 2010

Re: More than one primary key for a model

By definition a database table can have only one primary key. I
believe what you're looking to implement are compound primary keys.
Depending on the database backend you're using, the unique_together
Meta attribute may accomplish most of what you're looking to do.

On Jun 28, 12:49 pm, thusjanthan <thusjant...@gmail.com> wrote:
> Can anyone tell me why django refuses to follow the rules and lesson
> we learn in our database courses?
>
> I have a table that I do not have control over. Suppose its called the
> phone table and it contains the number and the username as the primary
> key. But for some reason when I have more than one primary key in
> django it complains. Especially when I run the test suite it just
> craps out saying more than one primary key detected for a model. Does
> django really expect all tables to only contain one primary key? How
> can I override this feature and have it take more than one primary key
> without using things suggested by django about the unique attr in the
> meta info of the model.
>
> Thanks.
> Nathan.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment