Author: mtredinnick
Date: 2008-09-03 00:53:50 -0500 (Wed, 03 Sep 2008)
New Revision: 8908

Modified:
   django/trunk/django/db/models/base.py
   django/trunk/tests/regressiontests/model_inheritance_regress/models.py
Log:
Fixed #8825 -- Fixed a small error model field setup (on the model class) from
r8855. Patch from Christofer Bernander. Test based on one from cgrady.


Modified: django/trunk/django/db/models/base.py
===================================================================
--- django/trunk/django/db/models/base.py       2008-09-03 05:42:08 UTC (rev 
8907)
+++ django/trunk/django/db/models/base.py       2008-09-03 05:53:50 UTC (rev 
8908)
@@ -87,13 +87,13 @@
                 # Things without _meta aren't functional models, so they're
                 # uninteresting parents.
                 continue
-                
+
             # All the fields of any type declared on this model
             new_fields = new_class._meta.local_fields + \
-                         new_class._meta.many_to_many + \
+                         new_class._meta.local_many_to_many + \
                          new_class._meta.virtual_fields
             field_names = set([f.name for f in new_fields])
-                
+
             # Concrete classes...
             if not base._meta.abstract:
                 if base in o2o_map:
@@ -106,7 +106,7 @@
                             auto_created=True, parent_link=True)
                     new_class.add_to_class(attr_name, field)
                 new_class._meta.parents[base] = field
-            
+
             # .. and abstract ones.
             else:
                 # Check for clashes between locally declared fields and those 
on the ABC.
@@ -127,7 +127,7 @@
                 if not val or val is manager:
                     new_manager = manager._copy_to_model(new_class)
                     new_class.add_to_class(mgr_name, new_manager)
-        
+
             # Inherit virtual fields (like GenericForeignKey) from the parent 
class
             for field in base._meta.virtual_fields:
                 if base._meta.abstract and field.name in field_names:
@@ -136,7 +136,7 @@
                                      'abstract base class %r' % \
                                         (field.name, name, base.__name__))
                 new_class.add_to_class(field.name, copy.deepcopy(field))
-        
+
         if abstract:
             # Abstract base models can't be instantiated and don't appear in
             # the list of models for an app. We do the final setup for them a

Modified: django/trunk/tests/regressiontests/model_inheritance_regress/models.py
===================================================================
--- django/trunk/tests/regressiontests/model_inheritance_regress/models.py      
2008-09-03 05:42:08 UTC (rev 8907)
+++ django/trunk/tests/regressiontests/model_inheritance_regress/models.py      
2008-09-03 05:53:50 UTC (rev 8908)
@@ -69,8 +69,14 @@
         return self.headline
 
 class ArticleWithAuthor(Article):
-    author = models.CharField(max_length=100) 
+    author = models.CharField(max_length=100)
 
+class M2MBase(models.Model):
+    articles = models.ManyToManyField(Article)
+
+class M2MChild(M2MBase):
+    name = models.CharField(max_length=50)
+
 __test__ = {'API_TESTS':"""
 # Regression for #7350, #7202
 # Check that when you create a Parent object with a specific reference to an
@@ -231,4 +237,9 @@
     ...
 DoesNotExist: ArticleWithAuthor matching query does not exist.
 
+# Regression test for #8825: Make sure all inherited fields (esp. m2m fields, 
in
+# this case) appear on the child class.
+>>> M2MChild.objects.filter(articles__isnull=False)
+[]
+
 """}


--~--~---------~--~----~------------~-------~--~----~
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