Search code examples
pythondjangodjango-templatesdjango-urlsdjango-userena

In django template urls are imported correctly but don't work


I am a total noob in Django, so it might seem I may miss something obvious.

I am using django userena app. Following official documentationv I include userena urls like this

from django.conf.urls import patterns, include, url 
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
   url(r'^accounts/', include('userena.urls')),
   url(r'^admin/', include(admin.site.urls)),
   url(r'^$', 'mysite.views.home', name='home'),
   # url(r'^blog/', include('blog.urls')),
)

And when I try to use some URL in my template they load correctly, but don't work.

        <div class="search_button" type="submit">
            Find
        </div>
        <div href="{% url 'userena_signin' %}" class="enter">
            Sign in
        </div>
        <div href="{% url 'userena_signup' %}" class="enter">
            Sign up
        </div>

When i load the page I can see correct URL

        <div href="/accounts/signin/" class="enter">
            Sign in
        </div>
        <div href="/accounts/signup/" class="enter">
            Sign up
        </div>

but pushing the button doesn't lead to neither sign in page, nor sign up. What did I miss?


Solution

  • href need to be applied on a < a > markup . You are using it on a div.

    Here is a correct version :

    <div class="search_button" type="submit">
        Find
    </div>
    <a href="{% url 'userena_signin' %}" class="enter">
        Sign in
    </a>
    <a href="{% url 'userena_signup' %}" class="enter">
        Sign up
    </a>
    

    Also < div type="submit" > normally apply on a < input /> markup, but may be you have some code fixing that I don't know.

    Seems to be pure HTML issue, nothing related to Django which is correctly used here ;)