Created
May 19, 2020 17:57
-
-
Save jourdanrodrigues/e60d43de76592b2dcdc9726a133ee97e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import migrations | |
def update_content_types(apps, schema_editor): | |
db_alias = schema_editor.connection.alias | |
ContentType = apps.get_model('contenttypes.ContentType') | |
ContentType.objects.using(db_alias).filter(app_label__in=['<old_app_1>', '<old_app_2>']).update(app_label='<remaining_app>') | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('<remaining_app>', '<file name of your latest migration>'), | |
] | |
operations = [ | |
migrations.RunPython(code=update_content_types, reverse_code=migrations.RunPython.noop) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment