diff options
| author | Robin Munn <robin.munn@gmail.com> | 2007-01-31 23:43:09 +0000 |
|---|---|---|
| committer | Robin Munn <robin.munn@gmail.com> | 2007-01-31 23:43:09 +0000 |
| commit | fe361e678a46dc4c717c79c2f12b3ba32293b81a (patch) | |
| tree | 8f42488e7d95244bab3db7b2bf934e006940521a /tests/modeltests/many_to_many/models.py | |
| parent | 122426e7453ed638a0c5be7e8b925adcddea3889 (diff) | |
Merged revisions 4186 to 4454 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@4455 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/many_to_many/models.py')
| -rw-r--r-- | tests/modeltests/many_to_many/models.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py index 357f3ca629..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') @@ -231,4 +243,16 @@ __test__ = {'API_TESTS':""" >>> p1.article_set.all() [<Article: NASA uses Python>] +# An alternate to calling clear() is to assign the empty set +>>> p1.article_set = [] +>>> p1.article_set.all() +[] + +>>> a2.publications = [p1, new_publication] +>>> a2.publications.all() +[<Publication: Highlights for Children>, <Publication: The Python Journal>] +>>> a2.publications = [] +>>> a2.publications.all() +[] + """} |
