403与django基于类的视图

Dee*_*eyi 0 python django post http-status-code-405 django-class-based-views

所以这是我写的一个简单的观点.

class PostTestView(View):
    def post(self, request, *args, **kwargs):
        print request.POST
        return HttpResponse("Hello there")
Run Code Online (Sandbox Code Playgroud)

urls.py对以上观点有这一行:

url(r'^test/create$',PostTestView.as_view(), name='app.views.create_test')
Run Code Online (Sandbox Code Playgroud)

但是405 Http error当我试图击中时,我得到了一个http://127.0.0.1:8000/app/test/create

这显然意味着我的方法post不在定义的方法列表中.但我在我看来已将其定义如上.这可能有什么问题?我很无能为力

esa*_*uro 6

尝试定义get方法.

"post"方法通常用于表单,但是当您将浏览器指向url时,使用的方法是"get"