69👍
✅
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
When using commit=False
, you have to call save_m2m()
m2m relationships require the parent object to be saved first, which you are not doing by using commit=False
22👍
You can do like this
for example:
if todo_list_form.is_valid():
todo_list = todo_list_form.save(commit=False)
todo_list.save()
todo_list_form.save_m2m()
👤Wagh
- [Django]-How to make a Django form retain a file after failing validation
- [Django]-Django "xxxxxx Object" display customization in admin action sidebar
- [Django]-TypeError while using django rest framework tutorial
Source:stackexchange.com