Search code examples
pythondjangodjango-settingsdjango-1.4

NoReverseMatch not a registered namespace, django 1.4 issue


I am forced to use django 1.4 to use neo4j, and I am getting a strange message that "accounts" isn't a registered namespace. It most certainly is, right there in the root:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^accounts/', include('accounts.urls', namespace='accounts')),
]

in settings.py:

INSTALLED_APPS = (
...
    'accounts',
)

TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'templates'), )

in project root I have templates/accounts/index.html, which looks right because template_dirs points to that folder. It specifically complains at:

return render(request, 'accounts/index.html', locals()) 

which isn't returning a namspace, it's returning a template name starting at the templates folder. In case it's relevant, in the accounts app (which is installed), I have:

urls.py-

from django.conf.urls   import patterns, include, url
from django.contrib     import admin

urlpatterns = patterns('accounts.views',
    url(r'^$',                                      'index',                    name='index'),
    url(r'^register/$',                             'register',                 name='register'),
    url(r'^login/$',                                'user_login_page',          name='login'),
    url(r'^logout/$',                               'user_logout',              name='logout'),

)

Why is something that has a namespace causing NoReverseMatch not a registered namespace?


Solution

  • Add this to top of your base html.

    {% load url from future %}