7👍
✅
In your get_success_url
method, check for the value of the submit button in self.request.POST
, and return the appropriate url:
def get_success_url(self):
if self.request.POST.get('save'):
return reverse('success_url_for_save')
elif self.request.POST.get('save_and_continue'):
return reverse('success_url_for_save_and_continue', kwargs={'pk':self.object.pk})
else:
return reverse('fallback_success_url')
Checking the values in the post
method shouldn’t be necessary.
Source:stackexchange.com