Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12245 -- Corrected target app handling for auto-generated m2m …

…models when the parent model isn't in the models module (or a subpackage thereof). Thanks to emulbreh for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11755 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 660f9086f15c7c1f76b489ea885223b36494e7fd 1 parent e6b4d10
Russell Keith-Magee authored November 20, 2009
11  django/db/models/fields/related.py
@@ -835,20 +835,13 @@ def set_managed(field, model, cls):
27  tests/modeltests/model_package/tests.py
... ...
@@ -1,4 +1,13 @@
1  
-"""
  1
+from django.db import models
  2
+
  3
+class Advertisment(models.Model):
  4
+    customer = models.CharField(max_length=100)
  5
+    publications = models.ManyToManyField("model_package.Publication", null=True, blank=True)
  6
+
  7
+    class Meta:
  8
+        app_label = 'model_package'
  9
+
  10
+__test__ = {'API_TESTS': """
2 11
 >>> from models.publication import Publication
3 12
 >>> from models.article import Article
4 13
 >>> from django.contrib.auth.views import Site
@@ -19,7 +28,6 @@
19 28
 >>> a.save()
20 29
 >>> a.publications.add(p)
21 30
 >>> a.sites.add(current_site)
22  
->>> a.save()
23 31
 
24 32
 >>> a = Article.objects.get(id=1)
25 33
 >>> a
@@ -29,6 +37,19 @@
29 37
 >>> a.sites.count()
30 38
 1
31 39
 
32  
-"""
  40
+# Regression for #12248 - Models can exist in the test package, too
  41
+
  42
+>>> ad = Advertisment(customer="Lawrence Journal-World")
  43
+>>> ad.save()
  44
+>>> ad.publications.add(p)
  45
+
  46
+>>> ad = Advertisment.objects.get(id=1)
  47
+>>> ad
  48
+<Advertisment: Advertisment object>
  49
+
  50
+>>> ad.publications.count()
  51
+1
  52
+
  53
+"""}
33 54
 
34 55
 

0 notes on commit 660f908

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