diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-01-29 16:09:25 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-01-29 16:09:25 +0000 |
| commit | d28a63cc008c2b62d1e82ecb5ff5a2d92e6a43ec (patch) | |
| tree | 6c7d21794678c114414d8407fc2b08eb3846a996 /tests | |
| parent | a031cadf4e946921b2897b00dea45389dff6fe85 (diff) | |
Fixed #3389 -- Many-to-many sets can now be assigned with primary key values
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4448 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/many_to_many/models.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py index 38f8931ee7..5e46ad428d 100644 --- a/tests/modeltests/many_to_many/models.py +++ b/tests/modeltests/many_to_many/models.py @@ -203,7 +203,19 @@ __test__ = {'API_TESTS':""" >>> p2.article_set.all() [<Article: Oxygen-free diet works wonders>] -# Recreate the article and Publication we just deleted. +# Relation sets can also be set using primary key values +>>> p2.article_set = [a4.id, a5.id] +>>> p2.article_set.all() +[<Article: NASA finds intelligent life on Earth>, <Article: Oxygen-free diet works wonders>] +>>> a4.publications.all() +[<Publication: Science News>] +>>> a4.publications = [p3.id] +>>> p2.article_set.all() +[<Article: Oxygen-free diet works wonders>] +>>> a4.publications.all() +[<Publication: Science Weekly>] + +# Recreate the article and Publication we have deleted. >>> p1 = Publication(id=None, title='The Python Journal') >>> p1.save() >>> a2 = Article(id=None, headline='NASA uses Python') |
