2
The answer is in your question: unique_together
.
Here is a reference to the official documentation:
https://docs.djangoproject.com/en/1.11/ref/models/options/#django.db.models.Options.unique_together
Example:
unique_together('user', 'group)
Assuming that user
and group
are referencing to other models, this should be set in the model (db table) that connects both models, conventionally called something like yourapp_user_group
.
Source:stackexchange.com