Author: russellm
Date: 2009-06-09 08:14:40 -0500 (Tue, 09 Jun 2009)
New Revision: 10967

Modified:
   django/trunk/django/core/management/commands/dumpdata.py
   django/trunk/tests/regressiontests/fixtures_regress/models.py
Log:
Fixed #11286 -- Ensured that dumpdata uses the default manager, rather than 
always using the manager called `objects`. Thanks to Marc Remolt for the report.

Modified: django/trunk/django/core/management/commands/dumpdata.py
===================================================================
--- django/trunk/django/core/management/commands/dumpdata.py    2009-06-09 
12:59:41 UTC (rev 10966)
+++ django/trunk/django/core/management/commands/dumpdata.py    2009-06-09 
13:14:40 UTC (rev 10967)
@@ -73,7 +73,7 @@
                 model_list = get_models(app)
 
             for model in model_list:
-                objects.extend(model.objects.all())
+                objects.extend(model._default_manager.all())
 
         try:
             return serializers.serialize(format, objects, indent=indent)

Modified: django/trunk/tests/regressiontests/fixtures_regress/models.py
===================================================================
--- django/trunk/tests/regressiontests/fixtures_regress/models.py       
2009-06-09 12:59:41 UTC (rev 10966)
+++ django/trunk/tests/regressiontests/fixtures_regress/models.py       
2009-06-09 13:14:40 UTC (rev 10967)
@@ -9,6 +9,9 @@
     count = models.IntegerField()
     weight = models.FloatField()
 
+    # use a non-default name for the default manager
+    specimens = models.Manager()
+
     def __unicode__(self):
         return self.common_name
 
@@ -161,4 +164,10 @@
 
 >>> models.signals.pre_save.disconnect(animal_pre_save_check)
 
+###############################################
+# Regression for #11286 -- Ensure that dumpdata honors the default manager
+# Dump the current contents of the database as a JSON fixture
+>>> management.call_command('dumpdata', 'fixtures_regress.animal', 
format='json')
+[{"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"}}]
+
 """}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to