[Fixed]-'admin' is not a registered namespace in Django 1.4


As it turns out, this was due to the order of the TEMPLATE_LOADERS key in my settings file.

I had the following:


which, somehow, caused the error when reversing admin URLs. Switching the two round solved the issue. I would love to know how this happens, as it isn’t reproducible in a blank Django 1.4 project.

What was reproducible, however, was the AttributeError for settings.AUTH_PROFILE_MODULE. Turns out this is a bug in Django 1.4, which was filed on release day here.


Short Answer: You have a copy of Django admin template files copied in on of your app’s templates directory from an earlier version of Django, then you upgraded Django but didn’t update (re-copy) those local templates.

Long Answer: The main cause of this problem is using an older version of Django admin template files (which are installed where django itself is installed, usually python’s site-packages or dist-packages directory). There is a backward incompatible change in Django 1.5 about url template tag, in which the first parameter must be a string, from Django 1.5 release notes:

One deprecated feature worth noting is the shift to “new-style” url
tag. Prior to Django 1.3, syntax like {% url myview %} was interpreted
incorrectly (Django considered “myview” to be a literal name of a
view, not a template variable named myview). Django 1.3 and above
introduced the {% load url from future %} syntax to bring in the
corrected behavior where myview was seen as a variable.

So, the problem is you have a copy of admin’s template files in one of your app’s templates folder, which is coppied from an earlier version of Django. This is usually done for overriding default admin templates. Because of the backward incompatible change noted, these outdated template file can not load in a newer Django environment, and cause the strange error: NoReverseMatch: u'admin' is not a registered namespace.

Changing order of TEMPLATE_LOADERS entries will ignore the local admin templates modifications in favor of default templates file (because default Django templates are loaded by complete path with filesystem.Loader). If the modifications are needed (which is usually the case), you must update your local admin template files from your new Django installation templates and reapply your modifications on them.

Note 1: A similar situation is when local admin templates are newer than Django installation’s default, which seems this is your case. Similarly, the better fix is to update all copies of admin templates.

Note 2: Another possibility of getting such error is when using virtualenv. For example, if you are running your project with a virtualenv but the TEMPLATE_DIRS entry for Django admin templates is to your global python installation, you may get this error.


Try add namespace=”admin” within the include method in the urls.py file.

ex: url(r’^admin/’, include(“someUrlpattern”, namespace=”admin”))


The app_directories template loader loads templates from the INSTALLED_APPS template directory, while the filesystem loader loads them from the templates directory configured in your TEMPLATE_DIRS settings.

Switching the two of them makes a huge difference because if you have custom templates in your app it will not load if the app_directories is at the top. If the filesystem loader is at the top, django will look for a template in your template directory first before loading the default one from the installed_apps.

That’s why it is not reproducible in a blank Django project. It will look for templates at the right places.


My solutuion was to upgrade django to the newest cersion:
pip install –upgrade django==1.6.1
before this, check your installed version:
pip freeze | grep Django
– I found that on release server there was an old version, upgrade solved this issue!


I had a similar error message happen to me because my URLs conf had 2 logout URLs defined .

urlpatterns = [
    url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'),
    url(r'^api/v1/', include(router.urls)),
    url(r'^logout/$', auth_views.logout, name='logout'),
    url(r'^login/$', auth_views.login, {'template_name': 'login.html'}, name='login'),
    url(r'^logout/$', auth_views.logout, {'template_name': 'logged_out.html'}, name='logout'),

Leave a comment