Django

Code

Changeset 2244

Show
Ignore:
Timestamp:
02/03/06 14:03:04 (3 years ago)
Author:
adrian
Message:

magic-removal: Fixed many_to_many and m2m_multiple model unit tests to use correct many-to-many manager name (the field name, not object_name +'_set')

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/tests/modeltests/m2m_multiple/models.py

    r2195 r2244  
    66 
    77Set ``related_name`` to designate what the reverse relationship is called. 
    8  
    9 Set ``singular`` to designate what the category object is called. This is 
    10 required if a model has multiple ``ManyToManyFields`` to the same object. 
    118""" 
    129 
     
    2421    headline = models.CharField(maxlength=50) 
    2522    pub_date = models.DateTimeField() 
    26     primary_categories = models.ManyToManyField(Category, 
    27         singular='primary_category', related_name='primary_article') 
    28     secondary_categories = models.ManyToManyField(Category, 
    29         singular='secondary_category', related_name='secondary_article') 
     23    primary_categories = models.ManyToManyField(Category, related_name='primary_article_set') 
     24    secondary_categories = models.ManyToManyField(Category, related_name='secondary_article_set') 
    3025    class Meta: 
    3126       ordering = ('pub_date',) 
     
    6459# would cause a conflict because the "primary_categories" and 
    6560# "secondary_categories" fields both relate to Category. 
    66 >>> a1.primary_category_set.all() 
     61>>> a1.primary_categories.all() 
    6762[Crime, News] 
    6863 
    6964# Ditto for the "primary_category" here. 
    70 >>> a2.primary_category_set.all() 
     65>>> a2.primary_categories.all() 
    7166[News, Sports] 
    7267 
    7368# Ditto for the "secondary_category" here. 
    74 >>> a1.secondary_category_set.all() 
     69>>> a1.secondary_categories.all() 
    7570[Life] 
    7671 
  • django/branches/magic-removal/tests/modeltests/many_to_many/models.py

    r2195 r2244  
    5757 
    5858# Article objects have access to their related Publication objects. 
    59 >>> a1.publication_set.all() 
     59>>> a1.publications.all() 
    6060[The Python Journal] 
    61 >>> a2.publication_set.all() 
     61>>> a2.publications.all() 
    6262[The Python Journal, Science News, Science Weekly] 
    6363 
     
    100100[Science News, Science Weekly] 
    101101>>> a1 = Article.objects.get(pk=1) 
    102 >>> a1.publication_set.all() 
     102>>> a1.publications.all() 
    103103[] 
    104104