Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

migrations.RunPython

from django.db import migrations

def forwards_func(apps, schema_editor):
    # We get the model from the versioned app registry;
    # if we directly import it, it'll be the wrong version

def reverse_func(apps, schema_editor):
    # reverse_func() reverse the anctions done inside forwards_func.

class Migration(migrations.Migration):
    dependencies = []
    operations = [
        migrations.RunPython(forwards_func, reverse_func),
    ]
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
4+4 =