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
2010-02-16 05:22:33
Thanks Ignacio! How to make this work with Many-to-Many relationship? Will it work?
Viet
2010-02-16 05:46:55
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
2010-02-16 05:55:27
Viet
2010-02-16 05:58:06
So then just put it in the through table.
Ignacio Vazquez-Abrams
2010-02-16 06:02:53
thanks. ok then :)
Viet
2010-02-16 06:09:54