Raise an error if an CreateView does not define a apply_url
This commit is contained in:
parent
3229d86d4d
commit
ae8641bcad
@ -241,6 +241,8 @@ class UpdateView(PermissionMixin, _UpdateView):
|
|||||||
|
|
||||||
|
|
||||||
class CreateView(PermissionMixin, _CreateView):
|
class CreateView(PermissionMixin, _CreateView):
|
||||||
|
apply_url = None
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
messages.success(self.request, self.get_success_message())
|
messages.success(self.request, self.get_success_message())
|
||||||
if 'apply' in self.request.POST:
|
if 'apply' in self.request.POST:
|
||||||
@ -254,7 +256,12 @@ class CreateView(PermissionMixin, _CreateView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def get_apply_url(self):
|
def get_apply_url(self):
|
||||||
|
if self apply_url:
|
||||||
return self.apply_url
|
return self.apply_url
|
||||||
|
else:
|
||||||
|
raise ImproperlyConfigured(
|
||||||
|
"No URL to redirect to. Provide a apply_url.")
|
||||||
|
|
||||||
|
|
||||||
def form_invalid(self, form):
|
def form_invalid(self, form):
|
||||||
messages.error(self.request, _('Please check the form for errors.'))
|
messages.error(self.request, _('Please check the form for errors.'))
|
||||||
|
Loading…
Reference in New Issue
Block a user