diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-09-20 01:12:24 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-09-20 01:12:24 +0000 |
| commit | 473306a6589697d2c977373207254d89dea2133f (patch) | |
| tree | 3079745909d64c91f0fde6d20f5307a1948fcfe7 /tests/testapp/models | |
| parent | e7982bb5b0f53203d627e5a3d4955f6e711f3fa3 (diff) | |
Added unit test to one_to_one model that confirms #527
git-svn-id: http://code.djangoproject.com/svn/django/trunk@648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/testapp/models')
| -rw-r--r-- | tests/testapp/models/one_to_one.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/testapp/models/one_to_one.py b/tests/testapp/models/one_to_one.py index 51b3efe733..7c1d669566 100644 --- a/tests/testapp/models/one_to_one.py +++ b/tests/testapp/models/one_to_one.py @@ -23,6 +23,13 @@ class Restaurant(meta.Model): def __repr__(self): return "%s the restaurant" % self.get_place().name +class Waiter(meta.Model): + restaurant = meta.ForeignKey(Restaurant) + name = meta.CharField(maxlength=50) + + def __repr__(self): + return "%s the waiter at %s" % (self.name, self.get_restaurant()) + API_TESTS = """ # Create a couple of Places. >>> p1 = places.Place(name='Demon Dogs', address='944 W. Fullerton') @@ -61,4 +68,10 @@ RestaurantDoesNotExist: Restaurant does not exist for {'place__id__exact': ...} Demon Dogs the restaurant >>> restaurants.get_object(pk=1) Demon Dogs the restaurant + +# Add a Waiter to the Restaurant. +>>> w = r.add_waiter(name='Joe') +>>> w.save() +>>> w +Joe the waiter at Demon Dogs the restaurant """ |
