Fixed #36128 -- Clarified auto-generated unique constraint on m2m through models.

This commit is contained in:
Clifford Gama 2025-02-10 09:52:27 +02:00 committed by Sarah Boyce
parent c09bceef68
commit ae2736ca3b
3 changed files with 22 additions and 8 deletions

View file

@ -2614,6 +2614,13 @@ we can do this with inline admin models. Suppose we have the following models::
date_joined = models.DateField()
invite_reason = models.CharField(max_length=64)
class Meta:
constraints = [
models.UniqueConstraint(
fields=["person", "group"], name="unique_person_group"
)
]
The first step in displaying this intermediate model in the admin is to
define an inline class for the ``Membership`` model::