7
i auth buid, django auth.login() yukarıda hata 500TypeError: giriş() 1 konumsal argüman alır, ancak 2
from rest_framework.response import Response
from rest_framework import status
from rest_framework.decorators import api_view
from django.contrib.auth.models import User
from django.contrib.auth import authenticate,logout,login
@api_view(['POST'])
def register(request):
user=User.objects.create_user(username=request.POST['username'],email=request.POST['email'],password=request.POST['password'])
return Response({'ok':'True'},status=status.HTTP_201_CREATED)
@api_view(['POST'])
def login(request):
user=authenticate(
username=request.POST['username'],
password=request.POST['password']
)
if user is not None:
login(request,user)
return Response({'ok':'True'},status=status.HTTP_200_OK)
else:
return Response({'ok':'False'},status=status.HTTP_401_UNAUTHORIZED)
Çok teşekkür ederim –
Bu güzel bir vuruş! – abcdn