Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.6.x] Fixed #20820 -- Model inheritance + m2m fixture loading regre…

…ssion

Tests by Tim Graham, report from jeroen.pulles@redslider.net.

Backport of 1ed77e7 from master
  • Loading branch information...
commit 2b1101a4a6acbf9350b62638a04edcf20ad83e97 1 parent 3ae585b
Anssi Kääriäinen authored August 20, 2013
11  django/db/models/fields/related.py
@@ -989,7 +989,16 @@ def get_foreign_related_value(self, instance):
10  tests/fixtures_regress/fixtures/special-article.json
... ...
@@ -0,0 +1,10 @@
  1
+[
  2
+    {
  3
+        "pk": 1,
  4
+        "model": "fixtures_regress.specialarticle",
  5
+        "fields": {
  6
+            "title": "Article Title 1",
  7
+            "channels": []
  8
+        }
  9
+    }
  10
+]
5  tests/fixtures_regress/models.py
@@ -70,6 +70,11 @@ class Meta:
70 70
         ordering = ('id',)
71 71
 
72 72
 
  73
+# Subclass of a model with a ManyToManyField for test_ticket_20820
  74
+class SpecialArticle(Article):
  75
+    pass
  76
+
  77
+
73 78
 # Models to regression test #11428
74 79
 @python_2_unicode_compatible
75 80
 class Widget(models.Model):
11  tests/fixtures_regress/tests.py
@@ -431,6 +431,17 @@ def test_loaddata_not_existant_fixture_file(self):
431 431
         self.assertTrue("No fixture 'this_fixture_doesnt_exist' in" in
432 432
             force_text(stdout_output.getvalue()))
433 433
 
  434
+    def test_ticket_20820(self):
  435
+        """
  436
+        Regression for ticket #20820 -- loaddata on a model that inherits
  437
+        from a model with a M2M shouldn't blow up.
  438
+        """
  439
+        management.call_command(
  440
+            'loaddata',
  441
+            'special-article.json',
  442
+            verbosity=0,
  443
+        )
  444
+
434 445
 
435 446
 class NaturalKeyFixtureTests(TestCase):
436 447
 

0 notes on commit 2b1101a

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