Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#7217 closed (wontfix)

ModelForm save method should take an optional dictionary.

Reported by: Peter of the Norse <RahmCoff@…> Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The only time we use save(commit=False) is when there are fields in the model that aren’t in the form. There are a lot of places where it looks like

form = SomeForm(request.POST)
instance =
instance.other_field = "some value"
instance.another_field = calulated_value()

There are literally dozens of places where I have that, but no other places that use commit=False. It would be better if there was a way to pass a dictionary of values like = {"other_field": "some value", "another_field": calculated_value()})

Change History (2)

comment:1 Changed 11 years ago by jkocherhans

Resolution: wontfix
Status: newclosed

You can create your instance before passing it into a ModelForm. I use this method almost exclusively.

obj = MyModel(
    other_field = "some value"
    another_field = calulated_value()
form = SomeForm(request.POST, instance=obj)
new_obj =

comment:2 Changed 11 years ago by Peter of the Norse <RahmCoff@…>

It took me a while to get back to my Django project, but you’re right, this is a much better way.

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