[英]“detail”: “Method \”GET\“ not allowed.” Django Rest Framework
[英]"detail": "Method \"GET\" not allowed." in TokenAuthentication Django rest framework
我正在嘗試通過遵循https://www.django-rest-framework.org/api-guide/authentication/來構建基於令牌的身份驗證系統。
但是在發送請求時,我收到一個錯誤消息作為響應:
{“詳細信息”:“不允許使用方法“GET”。” }
這是我迄今為止嘗試過的:
網址.py
urlpatterns = [
path('api-token-auth/', views.obtain_auth_token),
]
模型.py
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
Token.objects.create(user=instance)
視圖.py
def index(request):
return render(request,'index.html')
任何幫助都是有益的。
你需要做一個post請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.