Django

Code

Changeset 8908

Show
Ignore:
Timestamp:
09/03/08 00:53:50 (3 months ago)
Author:
mtredinnick
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/base.py

    r8855 r8908  
    8888                # uninteresting parents. 
    8989                continue 
    90                  
     90 
    9191            # All the fields of any type declared on this model 
    9292            new_fields = new_class._meta.local_fields + \ 
    93                          new_class._meta.many_to_many + \ 
     93                         new_class._meta.local_many_to_many + \ 
    9494                         new_class._meta.virtual_fields 
    9595            field_names = set([f.name for f in new_fields]) 
    96                  
     96 
    9797            # Concrete classes... 
    9898            if not base._meta.abstract: 
     
    107107                    new_class.add_to_class(attr_name, field) 
    108108                new_class._meta.parents[base] = field 
    109              
     109 
    110110            # .. and abstract ones. 
    111111            else: 
     
    128128                    new_manager = manager._copy_to_model(new_class) 
    129129                    new_class.add_to_class(mgr_name, new_manager) 
    130          
     130 
    131131            # Inherit virtual fields (like GenericForeignKey) from the parent class 
    132132            for field in base._meta.virtual_fields: 
     
    137137                                        (field.name, name, base.__name__)) 
    138138                new_class.add_to_class(field.name, copy.deepcopy(field)) 
    139          
     139 
    140140        if abstract: 
    141141            # Abstract base models can't be instantiated and don't appear in 
  • django/trunk/tests/regressiontests/model_inheritance_regress/models.py

    r8821 r8908  
    7070 
    7171class ArticleWithAuthor(Article): 
    72     author = models.CharField(max_length=100)  
     72    author = models.CharField(max_length=100) 
     73 
     74class M2MBase(models.Model): 
     75    articles = models.ManyToManyField(Article) 
     76 
     77class M2MChild(M2MBase): 
     78    name = models.CharField(max_length=50) 
    7379 
    7480__test__ = {'API_TESTS':""" 
     
    232238DoesNotExist: ArticleWithAuthor matching query does not exist. 
    233239 
     240# Regression test for #8825: Make sure all inherited fields (esp. m2m fields, in 
     241# this case) appear on the child class. 
     242>>> M2MChild.objects.filter(articles__isnull=False) 
     243[] 
     244 
    234245"""}