List Info

Thread: models, composite primary keys




models, composite primary keys
user name
2007-01-26 23:25:11
Hi guys,

Does anyone worked on some way to django models work with
composite
primary keys? I need to implement a login system and the
login should
be unique for an specified username and a specified site
url. I see the
ticket above and it seems the wasn't any advance after it.

http://code.
djangoproject.com/ticket/373

I think to use just unique constraint on database level, so
I can use
an autoincrement integer primary key. What is the best
approach when
talking about database level, using a primary key with
username and url
or a integer id and have a unique constraint to username and
url?

Best regards,

Michel


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: models, composite primary keys
user name
2007-01-30 12:19:48
On 1/27/07, Michel Thadeu Sabchuk <micheltsgmail.com> wrote:
> Does anyone worked on some way to django models work
with composite
> primary keys? I need to implement a login system and
the login should
> be unique for an specified username and a specified
site url. I see the
> ticket above and it seems the wasn't any advance after
it.
>
> http://code.
djangoproject.com/ticket/373
>
> I think to use just unique constraint on database
level, so I can use
> an autoincrement integer primary key. What is the best
approach when
> talking about database level, using a primary key with
username and url
> or a integer id and have a unique constraint to
username and url?

Sorry if you already knew this but it was not clear from the
above.
The normal way would be to simply use the
"unique_together" model Meta
attribute which automatically adds the necessary DB level
constraints.

-- 
Phil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )