Browse Source

fixup! Pokus o hack: při výrobě modelu na něj rovnou přesměrujeme původní contenttype.

pull/43/head
Pavel 'LEdoian' Turinsky 5 months ago
parent
commit
39d618834b
  1. 10
      various/migrations/0001_initial.py

10
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):

Loading…
Cancel
Save