diff options
Diffstat (limited to 'django/core/management/commands/dumpdata.py')
-rw-r--r-- | django/core/management/commands/dumpdata.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index 1468a92e6c..69c80ff09f 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -1,3 +1,5 @@ +import inspect +import warnings from collections import OrderedDict from django.apps import apps @@ -6,6 +8,10 @@ from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS, router +class ProxyModelWarning(Warning): + pass + + class Command(BaseCommand): help = ("Output the contents of the database as a fixture of the given " "format (using each model's default manager unless --all is " @@ -132,9 +138,15 @@ class Command(BaseCommand): Collate the objects to be serialized. If count_only is True, just count the number of objects to be serialized. """ - for model in serializers.sort_dependencies(app_list.items()): + models = serializers.sort_dependencies(app_list.items()) + for model in models: if model in excluded_models: continue + if model._meta.proxy and inspect.getmro(model)[1] not in models: + warnings.warn( + "%s is a proxy model and won't be serialized." % model._meta.label, + category=ProxyModelWarning, + ) if not model._meta.proxy and router.allow_migrate_model(using, model): if use_base_manager: objects = model._base_manager |