views:

397

answers:

1

How to create models and tables with Compound/Composite primary/unique key with Django?

+4  A: 

Django does not support compound primary keys. You can create a single compound unique key with Meta.unique_together.

Ignacio Vazquez-Abrams
Thanks Ignacio! How to make this work with Many-to-Many relationship? Will it work?
Viet
I'm *really* curious as to what you believe the connection between a compound unique key and a many-to-many relationship is...
Ignacio Vazquez-Abrams
Viet
So then just put it in the through table.
Ignacio Vazquez-Abrams
thanks. ok then :)
Viet