From 6fa54ec9fd81a83b792f50b53b0660f1861fefa9 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 3 Feb 2006 20:03:04 +0000 Subject: [PATCH] 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') git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2244 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/m2m_multiple/models.py | 15 +++++---------- tests/modeltests/many_to_many/models.py | 6 +++--- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/modeltests/m2m_multiple/models.py b/tests/modeltests/m2m_multiple/models.py index c17a2bc6ea..6cfe757f40 100644 --- a/tests/modeltests/m2m_multiple/models.py +++ b/tests/modeltests/m2m_multiple/models.py @@ -5,9 +5,6 @@ In this example, an Article can have many Categories (as "primary") and many Categories (as "secondary"). Set ``related_name`` to designate what the reverse relationship is called. - -Set ``singular`` to designate what the category object is called. This is -required if a model has multiple ``ManyToManyFields`` to the same object. """ from django.db import models @@ -23,10 +20,8 @@ class Category(models.Model): class Article(models.Model): headline = models.CharField(maxlength=50) pub_date = models.DateTimeField() - primary_categories = models.ManyToManyField(Category, - singular='primary_category', related_name='primary_article') - secondary_categories = models.ManyToManyField(Category, - singular='secondary_category', related_name='secondary_article') + primary_categories = models.ManyToManyField(Category, related_name='primary_article_set') + secondary_categories = models.ManyToManyField(Category, related_name='secondary_article_set') class Meta: ordering = ('pub_date',) @@ -63,15 +58,15 @@ True # specified the "singular" parameter, Django would just use "category", which # would cause a conflict because the "primary_categories" and # "secondary_categories" fields both relate to Category. ->>> a1.primary_category_set.all() +>>> a1.primary_categories.all() [Crime, News] # Ditto for the "primary_category" here. ->>> a2.primary_category_set.all() +>>> a2.primary_categories.all() [News, Sports] # Ditto for the "secondary_category" here. ->>> a1.secondary_category_set.all() +>>> a1.secondary_categories.all() [Life] diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py index 8677375197..6058952b53 100644 --- a/tests/modeltests/many_to_many/models.py +++ b/tests/modeltests/many_to_many/models.py @@ -56,9 +56,9 @@ True True # Article objects have access to their related Publication objects. ->>> a1.publication_set.all() +>>> a1.publications.all() [The Python Journal] ->>> a2.publication_set.all() +>>> a2.publications.all() [The Python Journal, Science News, Science Weekly] # Publication objects have access to their related Article objects. @@ -99,7 +99,7 @@ True >>> Publication.objects.all() [Science News, Science Weekly] >>> a1 = Article.objects.get(pk=1) ->>> a1.publication_set.all() +>>> a1.publications.all() [] # If we delete an Article, its Publications won't be able to access it.