No, it doesn't use unique_together to do the joins, but unique_together will enforce the uniqueness constraint of the compound key, and allow you to do a lookup of an object based on the compound key.
As Bruno explained, you'll have to use for surrogate primary keys the auto-generated integer primary keys that Django creates if you don't declare a primary key for the model, and let Django do its joins on that. The only other option (i.e. if you're working with a database that already exists and you can't change) would be to do all your queries in raw SQL and write the joins yourself. On Jun 28, 1:27 pm, thusjanthan <thusjant...@gmail.com> wrote: > Yes you are correct I am looking to implement the compounded primary > keys. Well the problem is I would like to have a many to many(m2m) > with two models that share a compounded primary key. However when I do > the m2m join it randomly pics one of the compounded keys and tries to > join them? :| Does the unique_together parameter fix that problem? as > in does it use the unique_together to do the joins? > > On Jun 28, 10:20 am, ringemup <ringe...@gmail.com> wrote: > > > 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.