Correction: empêcher d'ajouter 2 fois le même objet à la même collection

master
Olivier DOSSMANN 2018-01-18 20:31:09 +01:00
parent 083d10fc6e
commit 4dfe7f4285
1 changed files with 2 additions and 0 deletions

View File

@ -48,6 +48,8 @@ class Item(models.Model):
default=cls.DEFAULT_CHOICE,
verbose_name=_('status'))
status_field.contribute_to_class(cls, 'status')
# check that no other same item name on same collection exists
cls._meta.unique_together = (('collection', 'name'), )
class Meta:
abstract = True