Question

I am pretty new to Django. Now I try to using Django Rest Framework. I have my custom login template, and I want to POST my login form to the Rest Framework's login route (/api-auth/login by default). In my main urls.py I have:

url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))

So, in my template I'm trying to fetch url by namespace (rest_framework) and name (login):

<form id="loginForm" method="POST" action="{% url 'rest_framework:login' as login_url %}" name="loginForm">

But as a result I have empty action attribute in my form. Can someone explain me, what I'm doing wrong?

Was it helpful?

Solution

Take the as login_url out of your action tag:

<form id="loginForm" method="POST" action="{% url 'rest_framework:login' %}" name="loginForm">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top