[Django]-Get Model instance from Form without saving

53👍

model_instance = form.save(commit=False)

will return you a object of the model without saving to the DB

you can then add value of some field which is not available on form

model_instance.some_field = value
model_instance.save()
👤Ashok

9👍

Also:

model_instance = form.instance
# edit
model_instance.save()

Leave a comment