Přezdívka změněna na nepovinnou
This commit is contained in:
parent
2064bd8103
commit
3adbff1104
2 changed files with 33 additions and 1 deletions
32
seminar/migrations/0085_nepovinna_prezdivka.py
Normal file
32
seminar/migrations/0085_nepovinna_prezdivka.py
Normal file
|
@ -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),
|
||||
]
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue