From 21c1dd1320e3acdb9769ce979e79899e45cbbf3e Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 29 Oct 2017 11:57:18 +0100 Subject: [PATCH] Unique together remplace unique --- .../migrations/0027_auto_20171029_1156.py | 20 +++++++++++++++++++ cotisations/models.py | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 cotisations/migrations/0027_auto_20171029_1156.py diff --git a/cotisations/migrations/0027_auto_20171029_1156.py b/cotisations/migrations/0027_auto_20171029_1156.py new file mode 100644 index 00000000..8a9a4f0c --- /dev/null +++ b/cotisations/migrations/0027_auto_20171029_1156.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-29 10:56 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cotisations', '0026_auto_20171028_0126'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='name', + field=models.CharField(max_length=255), + ), + ] diff --git a/cotisations/models.py b/cotisations/models.py index 22daaf9a..51a839e8 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -246,7 +246,7 @@ class Article(models.Model): ('All', 'All'), ) - name = models.CharField(max_length=255, unique=True) + name = models.CharField(max_length=255) prix = models.DecimalField(max_digits=5, decimal_places=2) duration = models.PositiveIntegerField( help_text="Durée exprimée en mois entiers", @@ -266,6 +266,8 @@ class Article(models.Model): max_length=255 ) + unique_together = ('name', 'type_user') + def clean(self): if self.name.lower() == "solde": raise ValidationError("Solde est un nom d'article invalide")