Browse Source

Přezdívka změněna na nepovinnou

middleware_test
Jonas Havelka 4 years ago
parent
commit
3adbff1104
  1. 32
      seminar/migrations/0085_nepovinna_prezdivka.py
  2. 2
      seminar/models.py

32
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),
]

2
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,

Loading…
Cancel
Save