Merge pull request #4507 from normanjaeckel/ManyToManyMigrationsFix

Hotfix for #4501: Skipped many to many related objects autoupdate sig…
This commit is contained in:
Emanuel Schütze 2019-03-14 11:34:48 +01:00 committed by GitHub
commit 4950ca084f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import sys
from django.apps import apps
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
@ -49,6 +51,11 @@ def autoupdate_for_many_to_many_relations(sender, instance, **kwargs):
Send autoupdate for many-to-many related objects if the other side
is deleted.
"""
# Hotfix for #4501: Skip autoupdate for many-to-many related objects
# during migrations.
if "migrate" in sys.argv:
return
m2m_fields = (
field
for field in instance._meta.get_fields(include_hidden=True)