[英]403 with django's class based view
這是我寫的一個簡單視圖。
class PostTestView(View):
def post(self, request, *args, **kwargs):
print request.POST
return HttpResponse("Hello there")
我的urls.py
在上面的視圖中有以下一行:
url(r'^test/create$',PostTestView.as_view(), name='app.views.create_test')
但是當我嘗試點擊http://127.0.0.1:8000/app/test/create
時出現405 Http error
這顯然意味着我的方法post
不在已定義的方法列表中。 但是我認為上面已經定義了它。 這里可能出什么問題了? 我無能為力
嘗試定義get方法。
“ post”方法通常在表單中使用,但是當您僅將瀏覽器指向url時,使用的方法是“ get”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.