summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-09-09 08:55:29 -0400
committerGitHub <noreply@github.com>2016-09-09 08:55:29 -0400
commitdab653cadcd22a442fa4082f24304a0567de6cd2 (patch)
tree838e1ebee0389875067526738a483fa65152d0ba /tests/model_forms
parentaca939b6e545debd64c6464976abac8fd716b589 (diff)
Organized forms_tests test_regressions.py.
Diffstat (limited to 'tests/model_forms')
-rw-r--r--tests/model_forms/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 3974bec1e9..e4a73b0c46 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1453,6 +1453,22 @@ class ModelFormBasicTests(TestCase):
<option value="3">Live</option>
</select></li>''' % (self.w_woodward.pk, w_bernstein.pk, self.w_royko.pk, self.c1.pk, self.c2.pk, self.c3.pk, c4.pk))
+ def test_recleaning_model_form_instance(self):
+ """
+ Re-cleaning an instance that was added via a ModelForm shouldn't raise
+ a pk uniqueness error.
+ """
+ class AuthorForm(forms.ModelForm):
+ class Meta:
+ model = Author
+ fields = '__all__'
+
+ form = AuthorForm({'full_name': 'Bob'})
+ self.assertTrue(form.is_valid())
+ obj = form.save()
+ obj.name = 'Alice'
+ obj.full_clean()
+
class ModelChoiceFieldTests(TestCase):
def setUp(self):