Changes between Initial Version and Version 2 of Ticket #20742
- Timestamp:
- Jul 18, 2013, 3:49:53 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #20742
- Property Summary ModelForm primary_key update with instance set is executed as INSERT caused by is_valid() chaning the instance → ModelForm primary_key update with instance set is executed as INSERT caused by is_valid() changing the instance
- Property Resolution → needsinfo
- Property Status new → closed
-
Ticket #20742 – Description
initial v2 1 1 I do agree this is a bad database design but it's executed without any warning or anything in the docs so i want to open this ticket to allow the discussion of raising an Error or anything (e.g. an info in the docs @primary_key or modelform) not let anyone run into this mistake. 2 2 3 3 {{{ 4 #!python 4 5 class Test(models.Model): 5 6 email = models.CharField(max_length=100, primary_key=True) … … 15 16 16 17 # here instance is updated with new@example.com as pkey and django thinks it has to create a new model instance not updating the old instance 18 17 19 if form.is_valid(): 18 20 new_x = form.save() 19 21 new_x.save() 22 }}}