From aa713a5aa79b91b3957bd417f1fe22ac3084ba89 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 18 Mar 2021 14:49:48 +0100 Subject: [PATCH] Use blank=True for voters --- elections/migrations/0010_blank_voters.py | 28 +++++++++++++++++++++++ elections/models.py | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 elections/migrations/0010_blank_voters.py diff --git a/elections/migrations/0010_blank_voters.py b/elections/migrations/0010_blank_voters.py new file mode 100644 index 0000000..0a2d038 --- /dev/null +++ b/elections/migrations/0010_blank_voters.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.19 on 2021-03-18 13:48 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("elections", "0009_auto_20210318_1441"), + ] + + operations = [ + migrations.AlterField( + model_name="election", + name="voters", + field=models.ManyToManyField( + blank=True, related_name="cast_elections", to=settings.AUTH_USER_MODEL + ), + ), + migrations.AlterField( + model_name="question", + name="voters", + field=models.ManyToManyField( + blank=True, related_name="cast_questions", to=settings.AUTH_USER_MODEL + ), + ), + ] diff --git a/elections/models.py b/elections/models.py index 32ad8be..466d26a 100644 --- a/elections/models.py +++ b/elections/models.py @@ -37,6 +37,7 @@ class Election(models.Model): voters = models.ManyToManyField( settings.AUTH_USER_MODEL, related_name="cast_elections", + blank=True, ) results_public = models.BooleanField(_("résultats publics"), default=False) @@ -67,6 +68,7 @@ class Question(models.Model): voters = models.ManyToManyField( settings.AUTH_USER_MODEL, related_name="cast_questions", + blank=True, ) class Meta: @@ -82,6 +84,7 @@ class Option(models.Model): settings.AUTH_USER_MODEL, related_name="votes", through="Vote", + blank=True, ) # For now, we store the amount of votes received after the election is tallied nb_votes = models.PositiveSmallIntegerField(_("nombre de votes reçus"), default=0)