summaryrefslogtreecommitdiff
path: root/tests/testapp/models/m2o_recursive.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-08-25 22:51:30 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-08-25 22:51:30 +0000
commit25264c86048d442a4885dfebae94510e2fa0c1e4 (patch)
treebb02799b624fb0d6f931d208509ffbb50d00e358 /tests/testapp/models/m2o_recursive.py
parentaec0a73d73324820c767758afd250fc21a2896ef (diff)
Fixed #122 -- BIG, BACKWARDS-INCOMPATIBLE CHANGE. Changed model syntax to use fieldname=FieldClass() syntax. See ModelSyntaxChangeInstructions for important information on how to change your models
git-svn-id: http://code.djangoproject.com/svn/django/trunk@549 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/testapp/models/m2o_recursive.py')
-rw-r--r--tests/testapp/models/m2o_recursive.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/tests/testapp/models/m2o_recursive.py b/tests/testapp/models/m2o_recursive.py
index a0d211fc2c..27d13b4e7e 100644
--- a/tests/testapp/models/m2o_recursive.py
+++ b/tests/testapp/models/m2o_recursive.py
@@ -7,29 +7,25 @@ To define a many-to-one relationship between a model and itself, use
In this example, a ``Category`` is related to itself. That is, each
``Category`` has a parent ``Category``.
-Because of this recursive relationship, we need to tell Django what the
-relationships should be called. Set ``rel_name`` for this, and set
-``related_name`` to designate what the reverse relationship is called.
+Set ``related_name`` to designate what the reverse relationship is called.
"""
from django.core import meta
class Category(meta.Model):
- module_name = 'categories'
- fields = (
- meta.CharField('name', maxlength=20),
- meta.ForeignKey('self', null=True,
- rel_name='parent', related_name='child'),
- )
+ name = meta.CharField(maxlength=20)
+ parent = meta.ForeignKey('self', null=True, related_name='child')
+ class META:
+ module_name = 'categories'
def __repr__(self):
return self.name
API_TESTS = """
# Create a few Category objects.
->>> r = categories.Category(id=None, name='Root category', parent_id=None)
+>>> r = categories.Category(id=None, name='Root category', parent=None)
>>> r.save()
->>> c = categories.Category(id=None, name='Child category', parent_id=r.id)
+>>> c = categories.Category(id=None, name='Child category', parent=r)
>>> c.save()
>>> r.get_child_list()