From 3adbff11049f53ca0a71386bd18dbe2407c2275a Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Thu, 25 Jun 2020 01:15:01 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99ezd=C3=ADvka=20zm=C4=9Bn=C4=9Bna=20na=20?= =?UTF-8?q?nepovinnou?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0085_nepovinna_prezdivka.py | 32 +++++++++++++++++++ seminar/models.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 seminar/migrations/0085_nepovinna_prezdivka.py diff --git a/seminar/migrations/0085_nepovinna_prezdivka.py b/seminar/migrations/0085_nepovinna_prezdivka.py new file mode 100644 index 00000000..b3bd19a4 --- /dev/null +++ b/seminar/migrations/0085_nepovinna_prezdivka.py @@ -0,0 +1,32 @@ +# Generated by Django 2.2.13 on 2020-06-24 22:57 + +from django.db import migrations, models + +def smaz_prezdivku(apps, schema_editor): + Osoba = apps.get_model('seminar', 'Osoba') + + for o in Osoba.objects.filter(prezdivka=''): + o.prezdivka = None + o.save() + +def pridej_prezdivku(apps, schema_editor): + Osoba = apps.get_model('seminar', 'Osoba') + + for o in Osoba.objects.filter(prezdivka=None): + o.prezdivka = '' + o.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0084_clanek_cislo'), + ] + + operations = [ + migrations.AlterField( + model_name='osoba', + name='prezdivka', + field=models.CharField(blank=True, max_length=256, null=True, verbose_name='přezdívka'), + ), + migrations.RunPython(smaz_prezdivku, pridej_prezdivku), + ] diff --git a/seminar/models.py b/seminar/models.py index 91eff9b3..69e313b6 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -66,7 +66,7 @@ class Osoba(SeminarModelBase): prijmeni = models.CharField('příjmení', max_length=256) - prezdivka = models.CharField('přezdívka', max_length=256) + prezdivka = models.CharField('přezdívka', blank=True, null=True, max_length=256) # User, pokud má na webu účet user = models.OneToOneField(settings.AUTH_USER_MODEL, blank=True, null=True,