Skip to content
Advertisement

Tag: primary-key

How can I set two primary key fields for my models in Django?

I have a model like this: How can I have the primary key be the combination of migration and host? Answer Update Django 4.0 Django 4.0 documentation recommends using UniqueConstraint with the constraints option instead of unique_together. Use UniqueConstraint with the constraints option instead. UniqueConstraint provides more functionality than unique_together. unique_together may be deprecated in the future. Original Answer I

Advertisement