Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11286 -- Ensured that dumpdata uses the default manager, rathe…

…r than always using the manager called `objects`. Thanks to Marc Remolt for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10967 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d3bd3203f9d202ed781d204f283459df87139bc5 1 parent 64be8f2
Russell Keith-Magee authored June 09, 2009
2  django/core/management/commands/dumpdata.py
@@ -73,7 +73,7 @@ def handle(self, *app_labels, **options):
73 73
                 model_list = get_models(app)
74 74
 
75 75
             for model in model_list:
76  
-                objects.extend(model.objects.all())
  76
+                objects.extend(model._default_manager.all())
77 77
 
78 78
         try:
79 79
             return serializers.serialize(format, objects, indent=indent)
9  tests/regressiontests/fixtures_regress/models.py
@@ -9,6 +9,9 @@ class Animal(models.Model):
9 9
     count = models.IntegerField()
10 10
     weight = models.FloatField()
11 11
 
  12
+    # use a non-default name for the default manager
  13
+    specimens = models.Manager()
  14
+
12 15
     def __unicode__(self):
13 16
         return self.common_name
14 17
 
@@ -161,4 +164,10 @@ class Meta:
161 164
 
162 165
 >>> models.signals.pre_save.disconnect(animal_pre_save_check)
163 166
 
  167
+###############################################
  168
+# Regression for #11286 -- Ensure that dumpdata honors the default manager
  169
+# Dump the current contents of the database as a JSON fixture
  170
+>>> management.call_command('dumpdata', 'fixtures_regress.animal', format='json')
  171
+[{"pk": 1, "model": "fixtures_regress.animal", "fields": {"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}, {"pk": 2, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 2.29..., "name": "Platypus", "latin_name": "Ornithorhynchus anatinus"}}, {"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}]
  172
+
164 173
 """}

0 notes on commit d3bd320

Please sign in to comment.
Something went wrong with that request. Please try again.