【发布时间】:2013-03-01 06:33:00
【问题描述】:
演示:
from django.views.generic.base import View
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
class TestView(View):
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return HttpResponse('haha')
urls.py 是
url(r'^test/', TestView.as_view()),
所以当 GET 时你可以看到 haha,但是当你做 POST 时你会得到一个空白页...
我在这里缺少什么?
编辑:澄清我在做什么。我正在编写一个 JSON 流 CURD 视图,我需要以各种方式解析 JSON。其中之一是当 ppl POST 具有特定模式的数据时,视图将分派到视图内的另一个方法并返回一些东西。但事实证明什么都没有返回。因此,我向您介绍了最小的 PoC。请帮助我我的代码出了什么问题。蒂亚!
【问题讨论】:
标签: python django post django-views django-class-based-views