summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
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):