python - Two different submit buttons in same form in Django -
python - Two different submit buttons in same form in Django -
i have updateview in django.
i have normal submit button. when object updated correctly redirects object list via success_url
.
can create 2 different submit buttons: 1 button submits , redirects objects list page (listview) , button submits , redirects object detail page (detailview)?
i don't know how in smart way.
since you're submitting same place, , want alter redirect destination after save, simple. submit buttons other input controls in have name , value, , receive these in post data. so, in template can have:
<input type="submit" name="list" value="submit , go list"> <input type="submit" name="detail" value="submit , go detail">
and in view:
if form.is_valid(): form.save() if 'list' in request.post: homecoming redirect('list_url') else: homecoming redirect('detail_url')
python django forms django-models django-forms
Comments
Post a Comment