From bc1b6e84c27379d4128bb785fbc4b79364be5d6a Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Thu, 1 Jul 2021 02:52:52 +0200 Subject: [PATCH] Pokus o fix polymorfismu (cislo bambilion) Pardon, testuji na produkci :-/ --- seminar/migrations/0095_fix_polymorphism.py | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 seminar/migrations/0095_fix_polymorphism.py diff --git a/seminar/migrations/0095_fix_polymorphism.py b/seminar/migrations/0095_fix_polymorphism.py new file mode 100644 index 00000000..cba9bda1 --- /dev/null +++ b/seminar/migrations/0095_fix_polymorphism.py @@ -0,0 +1,25 @@ +# Generated by Django 2.2.17 on 2021-07-01 00:44 + +from django.db import migrations + +def fix_all(apps, schema_editor): + ContentType = apps.get_model('contenttypes', 'ContentType') + for modelname in [ + # Problémy: + 'Konfera', 'Tema', 'Uloha', 'Clanek' + # TreeNody: + 'RocnikNode', 'CisloNode', 'MezicisloNode', 'TemaVCisleNode', 'OrgTextNode', 'UlohaZadaniNode', 'PohadkaNode', 'UlohaVzorakNode', 'TextNode', 'CastNode', 'ReseniNode' + ]: + Model = apps.get_model('seminar', modelname) + ct = ContentType.objects.get_for_model(Model) + Model.objects.update(polymorphic_ctype_id=ct) + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0094_auto_20210701_0149'), + ] + + operations = [ + migrations.RunPython(fix_all, migrations.RunPython.noop), + ]