Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7026 -- Fixed misleading/incorrect exception text when adding …

…to a many-to-many set on an object that doesn't yet have a primary-key value. Thanks for the report, ryan@peaceworks.ca

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7622 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5309e18cbfc85823d1c58e389fd122fff6e17eea 1 parent 0fd41d6
Adrian Holovaty authored June 12, 2008
2  django/db/models/fields/related.py
@@ -351,7 +351,7 @@ def __init__(self, model=None, core_filters=None, instance=None, symmetrical=Non
8  tests/modeltests/many_to_many/models.py
@@ -39,6 +39,14 @@ class Meta:
39 39
 
40 40
 # Create an Article.
41 41
 >>> a1 = Article(id=None, headline='Django lets you build Web apps easily')
  42
+
  43
+# You can't associate it with a Publication until it's been saved.
  44
+>>> a1.publications.add(p1)
  45
+Traceback (most recent call last):
  46
+...
  47
+ValueError: 'Article' instance needs to have a primary key value before a many-to-many relationship can be used.
  48
+
  49
+# Save it!
42 50
 >>> a1.save()
43 51
 
44 52
 # Associate the Article with a Publication.

0 notes on commit 5309e18

Please sign in to comment.
Something went wrong with that request. Please try again.