-1
html 템플릿 django에 로그인하기위한 API가 필요합니다.
URLS.PYhtml 템플릿에 로그인하기위한 API
from django.conf.urls import url
from Average import views
from Average.apis import *
urlpatterns=[
url(r'^add/fav/(?P<roll>[0-9]+)',add_fav),
url(r'^favs/',get_favs),
url(r'^auth/',authenticate)
]
apis.py
@api_view(['POST','GET'])
def authenticate(request):
if request.method=="POST":
k = User.objects.all().filter(id=1)
serialized = UserSerializer(k,many=True)
return Response(serialized.data)
#I just returned the superuser id. To check if it is working. Forget
#it
그리고 마지막으로 내 HTML 템플릿 :
템플릿
<form method="post" class="right" action="/api/auth/">
<input style="width:200px" type="text" class="form-control line">
<input style="width:200px" type="password" class="form-control line">
<button class="btn btn-primary line">Login</button></form>