You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We had a situation arise with an application written in 2017 using a home-grown ModelManager which works similarly to the SafeDeleteManager. Because we are migrating from one database to another, and there is not too much data, we attempted to use the management commands dumpdata and loaddata to copy the data to the new database instance.
This caused referential integrity errors because dumpdata did not include the deleted models. My suggestion is that safedelete includes its own dumpdata command which avoids the problem:
fromtypesimportMethodTypefromdjango.appsimportappsfromdjango.dbimportmodelsfromdjango.core.management.commands.dumpdataimportCommandasBaseCommand# not quite using django-safedelete, but other apps here dofromlrmaint.modelsimportSoftDeleteManagerclassCommand(BaseCommand):
defhandle(self, *app_labels, **options):
print('This is a wrapper around Django default dumpdata')
# patch each softdeletemanager to avoid overloadformodelinapps.get_app_config('lrmaint').get_models():
ifisinstance(model.objects, SoftDeleteManager):
model.objects.get_queryset=MethodType(models.Manager.get_queryset, model.objects)
# defer to dumpdatasuper().handle(*app_labels, **options)
The text was updated successfully, but these errors were encountered:
We had a situation arise with an application written in 2017 using a home-grown ModelManager which works similarly to the SafeDeleteManager. Because we are migrating from one database to another, and there is not too much data, we attempted to use the management commands dumpdata and loaddata to copy the data to the new database instance.
This caused referential integrity errors because dumpdata did not include the deleted models. My suggestion is that safedelete includes its own dumpdata command which avoids the problem:
The text was updated successfully, but these errors were encountered: