Fix migrace: cislo_body může být None

This commit is contained in:
Jonas Havelka 2022-10-11 11:24:21 +02:00
parent ad1b0e238c
commit ffab712aec

View file

@ -11,7 +11,7 @@ def prirad_deadliny(apps, schema_editor):
Deadline = apps.get_model('seminar', 'Deadline') Deadline = apps.get_model('seminar', 'Deadline')
for h in Hodnoceni.objects.all(): for h in Hodnoceni.objects.all():
if h.cislo_body.rocnik.rocnik < 26: if h.cislo_body is not None and h.cislo_body.rocnik.rocnik < 26:
# Deadline připravený v minulé migraci # Deadline připravený v minulé migraci
h.deadline_body = h.cislo_body.deadline_v_cisle.get() h.deadline_body = h.cislo_body.deadline_v_cisle.get()
h.save() h.save()