From 1679d820a7dd6eda8ed0ffe1eacb9abc808a3fb7 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Thu, 2 Jun 2022 14:26:28 +0200 Subject: [PATCH] Add django-admin export and import commands, making dump-data and loaddata django-scopes compatible --- cookbook/management/commands/export.py | 8 ++++++++ cookbook/management/commands/import.py | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 cookbook/management/commands/export.py create mode 100644 cookbook/management/commands/import.py diff --git a/cookbook/management/commands/export.py b/cookbook/management/commands/export.py new file mode 100644 index 000000000..82322a665 --- /dev/null +++ b/cookbook/management/commands/export.py @@ -0,0 +1,8 @@ +from django.core.management.commands.dumpdata import Command as DumpdataCommand +from django_scopes import scopes_disabled + + +class Command(DumpdataCommand): + def handle(self, *args, **options): + with scopes_disabled(): + return super().handle(*args, **options) diff --git a/cookbook/management/commands/import.py b/cookbook/management/commands/import.py new file mode 100644 index 000000000..986993c06 --- /dev/null +++ b/cookbook/management/commands/import.py @@ -0,0 +1,8 @@ +from django.core.management.commands.loaddata import Command as LoaddataCommand +from django_scopes import scopes_disabled + + +class Command(LoaddataCommand): + def handle(self, *args, **options): + with scopes_disabled(): + return super().handle(*args, **options)