Opened 6 months ago

Last modified 2 months ago

#23387 assigned Bug

Error when saving inline formsets as new after a validation error.

Reported by: johnrtipton Owned by: jayadeepk
Component: contrib.admin Version: master
Severity: Normal Keywords: admin formset validation base10
Cc: karnatijayadeep@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by johnrtipton)

This bug seems to have been around for a long time, as I've tried this from version 1.4 up.

While in the admin, if you have a form with inline formsets and you try to do a save as new, it works properly, unless there is a validation error. If you get a validation error, Django sends you through the add_view which no longer has the "Save as new" option. If you click save here, you will get the error below:

ValueError at /admin/drawings/sow/add/
invalid literal for int() with base 10:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/drawings/sow/add/
Django Version: 1.6.6.dev20140829183230
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10:

Exception Location: /Users/tip/Dropbox/websites/isotekrms/django/db/models/fields/init.py in get_prep_value, line 613
Python Executable: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.6

I, have written a small patch that will check to see if the formset had validation errors and it was submitted as a save as new, it will set the context variable change=True which causes the "Save as new" button to show on the form again. Fixing the validation errors on the screen and pressing "Save as new" again will save the form properly.

Attachments (3)

formset_save_as_validation.patch (637 bytes) - added by johnrtipton 6 months ago.
Patch
formset_save_as_validation.2.patch (666 bytes) - added by johnrtipton 6 months ago.
Updated Patch.
formset_save_as_validation.3.patch (2.2 KB) - added by johnrtipton 5 months ago.

Download all attachments as: .zip

Change History (10)

Changed 6 months ago by johnrtipton

Patch

comment:1 Changed 6 months ago by johnrtipton

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Changed 6 months ago by johnrtipton

Updated Patch.

comment:2 Changed 6 months ago by johnrtipton

  • Description modified (diff)

comment:3 Changed 6 months ago by timgraham

  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

The patch also requires tests.

comment:4 Changed 5 months ago by raulcd

  • Owner changed from nobody to raulcd
  • Status changed from new to assigned

Changed 5 months ago by johnrtipton

comment:5 Changed 5 months ago by johnrtipton

Updated patch to hide "Save" and "Save and Continue" buttons after a validation error when try to Save as New.

If you try to Save as New and get a validation error, you must hit Save as New again or you will get the previously mentioned error.

comment:6 Changed 3 months ago by raulcd

  • Owner raulcd deleted
  • Status changed from assigned to new

comment:7 Changed 2 months ago by jayadeepk

  • Cc karnatijayadeep@… added
  • Owner set to jayadeepk
  • Status changed from new to assigned
  • Version changed from 1.6 to master

The bug is reproducible in master version.

Note: See TracTickets for help on using tickets.
Back to Top