我知道这是由于视图的代码路径显然不返回HttpResponse
. 我是 django 的新手,所以这可能是完全错误的。
这是 FormView 代码。我需要覆盖render_to_response
吗?
class AddAdvertView(FormView):
form_class = NewAdForm
def get(self, *args, **kwargs):
self.campaign = get_object_or_404(Campaign, id__exact = self.kwargs['campaign_id'])
def post(self, request, *args, **kwargs):
pass
def get_form(self, form_class):
return form_class(initial = {}, campaign = self.campaign)
def get_success_url(self):
return self.request.META.get('HTTP_REFERER', None)
def form_valid(self, form):
return HttpResponse('form valid')
def form_invalid(self, form):
return HttpResponse('form invalid')