mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
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
This commit is contained in:
parent
a031cadf4e
commit
d28a63cc00
2 changed files with 24 additions and 8 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue