Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.1 KiB
30 lines
1.1 KiB
![]()
5 years ago
|
# Generated by Django 2.2.4 on 2019-08-13 19:45
|
||
|
|
||
|
from django.db import migrations, models
|
||
|
import django.db.models.deletion
|
||
|
|
||
|
def vyrob_problemum_ctypes(apps, schema_editor):
|
||
|
# Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html
|
||
|
# XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i)
|
||
|
Problem = apps.get_model('seminar', 'Problem')
|
||
|
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||
|
|
||
|
new_ct = ContentType.objects.get_for_model(Problem)
|
||
|
Problem.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct)
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
|
('contenttypes', '0002_remove_content_type_name'),
|
||
|
('seminar', '0065_treenode_polymorphic_ctype'),
|
||
|
]
|
||
|
|
||
|
operations = [
|
||
|
migrations.AddField(
|
||
|
model_name='problem',
|
||
|
name='polymorphic_ctype',
|
||
|
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.problem_set+', to='contenttypes.ContentType'),
|
||
|
),
|
||
|
migrations.RunPython(vyrob_problemum_ctypes, migrations.RunPython.noop),
|
||
|
]
|