Split Apps: oddělení personálních modelů #43
1 changed files with 6 additions and 4 deletions
|
@ -4,13 +4,15 @@ from django.db import migrations, models
|
||||||
|
|
||||||
def nastav_nove_contenttypes(apps, schema_editor):
|
def nastav_nove_contenttypes(apps, schema_editor):
|
||||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||||
old_ct = ContentType.objects.get_by_natural_key('seminar', 'nastaveni')
|
old_ct = ContentType.objects.filter(app_label='seminar', model='nastaveni')
|
||||||
old_ct.update(appname='various')
|
# 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):
|
def nastav_stare_contenttypes(apps, schema_editor):
|
||||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||||
new_ct = ContentType.objects.get_by_natural_key('various', 'nastaveni')
|
new_ct = ContentType.objects.filter(app_label='various', model='nastaveni')
|
||||||
new_ct.update(appname='seminar')
|
new_ct.update(app_label='seminar')
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue