Django url parsing error -


ok, have 2 different views, both in project site-wide area.

urls.py

url(r'^accounts/login/$', 'taxo.views.login'), url(r'^accounts/invalid/$', 'taxo.views.invalid'), ... 

taxo/views.py

def login(request):     c = {}     c.update(csrf(request))     return render_to_response('login.html', c) def invalid(request):     return render_to_response('invalid.html',{'title':'invalid'}) 

templates/login.html

<form action="/accounts/auth/" method="post">{% csrf_token %}    <label for="username">user name</label>    <input type="text" name="username" value="" id="username">    <label for="password">password</label>    <input type="password" name="password" value="" id="password">    <input type="submit" value="login" /> </form> 

templates/invalid.html

<form style="float: right" action="accounts/login/" method="post">   {% csrf_token %}   {{form}}   <input type="submit" value="login" class="search"/> </form> 

with above code, got page not found error

page not found (404) request method: post request url: http://127.0.0.1:8000/accounts/invalid/accounts/login/ 

django parses requested url relative url of current page. when replaced action {% url %} tag. got noreversematch @ /accounts/invalid/ error

how do correctly?

try this:

<form style="float: right" action="/accounts/login/" method="post">   {% csrf_token %}   {{form}}   <input type="submit" value="login" class="search"/> </form> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -