def dispatch(self, request, *args, **kwargs): """Overriding dispatch on DeleteView""" self.model = get_model(**kwargs) instance = get_model_instance(**kwargs) app_title = get_app_name(**kwargs) self.success_url = reverse_lazy( 'index', args=(app_title, instance.title,)) return super(EntityDelete, self).dispatch( request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): """Overriding dispatch on DeleteView""" self.model = get_model(**kwargs) instance = get_model_instance(**kwargs) app_title = get_app_name(**kwargs) self.success_url = reverse_lazy('index', args=( app_title, instance.title, )) return super(EntityDelete, self).dispatch(request, *args, **kwargs)
def post(self, request, **kwargs): """POST request handler for Create operation""" model = get_model(**kwargs) form = get_form_instance(**kwargs)(request.POST) app_title = get_app_name(**kwargs) if form.is_valid(): instance = model(**form.cleaned_data) instance.save() return HttpResponseRedirect( reverse('index', args=( app_title, instance.title, ))) else: context = {'form': form, 'error_message': get_errors(form.errors)} return render_to_response('core/create.html', context, context_instance=RequestContext(request))
def post(self, request, **kwargs): """POST request handler for Create operation""" model = get_model(**kwargs) form = get_form_instance(**kwargs)(request.POST) app_title = get_app_name(**kwargs) if form.is_valid(): instance = model(**form.cleaned_data) instance.save() return HttpResponseRedirect( reverse('index', args=( app_title, instance.title,))) else: context = { 'form': form, 'error_message': get_errors(form.errors) } return render_to_response( 'core/create.html', context, context_instance=RequestContext(request))
def dispatch(self, request, *args, **kwargs): """Overriding dispatch on DetailView""" self.model = get_model(**kwargs) return super(EntityDetail, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): """Overriding dispatch on DetailView""" self.model = get_model(**kwargs) return super(EntityDetail, self).dispatch( request, *args, **kwargs)