diff --git a/various/migrations/0001_initial.py b/various/migrations/0001_initial.py index 1cc24c3d..38f2a029 100644 --- a/various/migrations/0001_initial.py +++ b/various/migrations/0001_initial.py @@ -4,13 +4,15 @@ from django.db import migrations, models def nastav_nove_contenttypes(apps, schema_editor): ContentType = apps.get_model('contenttypes', 'ContentType') - old_ct = ContentType.objects.get_by_natural_key('seminar', 'nastaveni') - old_ct.update(appname='various') + old_ct = ContentType.objects.filter(app_label='seminar', model='nastaveni') + # Pozn: tohle může být prázdné (pokud Django nedostalo signál o dokončených migracích, např. při vyrábění databáze z nuly) + # Ale .update to nevadí… + old_ct.update(app_label='various') def nastav_stare_contenttypes(apps, schema_editor): ContentType = apps.get_model('contenttypes', 'ContentType') - new_ct = ContentType.objects.get_by_natural_key('various', 'nastaveni') - new_ct.update(appname='seminar') + new_ct = ContentType.objects.filter(app_label='various', model='nastaveni') + new_ct.update(app_label='seminar') class Migration(migrations.Migration):