I am trying to build a token-based authentication system by following https://www.django-rest-framework.org/api-guide/authentication/.
But on sending a request, I am getting an error msg as a response:
{ "detail": "Method "GET" not allowed." }
Here is what I have tried so far:
urls.py
urlpatterns = [
path('api-token-auth/', views.obtain_auth_token),
]
models.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)
views.py
def index(request):
return render(request,'index.html')
Any help would be beneficial.