Django 2.0 'name' is not a registered namespace

Django 2.0 'name' is not a registered namespace

I've seen this error posted several times, but I can't find anyone using Django 2.0 and having the problem.

The problem cropped up when I tried to nest one app inside another. The nested app (called "users") is meant to allow users to login and out. After putting that segment in, I'm getting the following error:

Template error:
In template C:\Users\arbit\Documents\python\learning_log\learning_logs\templates\learning_logs\base.html, error at line 6
   'users' is not a registered namespace
   1 : <p>
   2 :     <a href="{% url 'learning_logs:index' %}">Learning Log</a> 
   3 :     <a href="{% url 'learning_logs:topics' %}">Topics</a> 
   4 :     {% if user.is_authenticated %}
   5 :         Hello, {{ user.username }}.
   6 :         <a href=" {% url 'users:logout' %} ">log out</a>
   7 :     {% else %}
   8 :         <a href="{% url 'users:login' %}">log in</a>
   9 :     {% endif %}
   10 : </p>
   11 : 
   12 : {% block content %}{% endblock content %}
   13 : 

Here's my root

from django.urls import path, include
from django.contrib import admin

from . import views

app_name = "learning_log"

urlpatterns = [
    path('users/', include('users.urls')),
    path('', include('learning_logs.urls')),

urlpatterns = [
    # Home page
    path('', views.index, name='index'),

    # Show all topics
    path('topics/', views.topics, name='topics'),

    # Detail page for a single topic
    path('topics/<int:topic_id>/', views.topic, name='topic'),

    # Page for adding a new topic
    path('new_topic/', views.new_topic, name='new_topic'),

    # Page for adding a new entry
    path('new_entry/<int:topic_id>/', views.new_entry, name='new_entry'),

    # Page for editing an entry
    path('edit_entry/<int:entry_id>/', views.edit_entry, name='edit_entry'),

... and the app "users"

from django.urls import path
from django.contrib.auth.views import login

from . import views

app_name = 'users'

urlpatterns = [
    # Login page.
    path('login/', login, {'template_name': 'users/login.html'}, name='login'),

    # Logout page
    path('logout/', views.logout_view, name='logout'),

and the base.html from the "users" app

    <a href="{% url 'learning_logs:index' %}">Learning Log</a> 
    <a href="{% url 'learning_logs:topics' %}">Topics</a> 
    {% if user.is_authenticated %}
        Hello, {{ user.username }}.
        <a href="{% url 'users:logout' %}">log out</a>
    {% else %}
        <a href="{% url 'users:login' %}">log in</a>
    {% endif %}

{% block content %}{% endblock content %}

I'm admittedly using an older tutorial and thus am sure the problem has to do with something that is in Django 2.0 but not in the older version that the book covers. Your help is greatly appreciated.

There are two ways can hanlded this.

Firstly,you can set an app_name attribute in the included URLconf module, at the same level as the urlpatterns attribute. You have to pass the actual module, or a string reference to the module, to include(), not the list of urlpatterns itself.

from django.urls import include, path

urlpatterns = [
    path('polls/', include('polls.urls')),


from django.urls import path

from . import views

app_name = 'polls'
urlpatterns = [
    path('', views.IndexView.as_view(), name='index'),
    path('<int:pk>/', views.DetailView.as_view(), name='detail'),

have fun!

Download Django, With the release of Django 2.0, Django 1.11 has reached the end of mainstream support. The final minor bug fix release, 1.11.8, was issued today  How to get Django. Django is available open-source under the BSD license.We recommend using the latest version of Python 3. The last version to support Python 2.7 is Django 1.11 LTS.

Set users as the value of the namespace keyword argument of include method to set the appropriate application namespace:

path('users/', include('users.urls', namespace='users'))

Django 2.0 released | Weblog, Django 2.0.10 fixes a security issue and several bugs in 2.0.9. CVE-2019-3498: Content spoofing possibility in the default 404  Building Django 2.0 Web Applications: Create enterprise-grade, scalable Python web applications easily with Django 2.0 [Aratyn, Tom] on *FREE* shipping on qualifying offers.

You need to actually tell it what the namespace is.

Change this line:

path('users/', include('users.urls')),


path('users/', include('users.urls', namespace="users")),

Read the documentation

Django 2.0.10 release notes | Django documentation, 2 fixes a security issue and several bugs in 2.0.1. CVE-2018-6188: Information leakage in AuthenticationForm ¶. A regression in Django 1.11.8  Learn Django in this video by following along as I show you how to build a simple hello world app and then a guestbook app that uses the templates, models, and form functionality with Django

Because the "learning_logs" URL namespaces includes the "users" one, they are considered to be nested. So when you want to find a URL inside "users" you need to use both names in your url tags:

<a href="{% url 'learning_logs:users:logout' %}">log out</a>

Django 2.0.2 release notes | Django documentation, 12/2.0.11. Bugfixes¶. Fixed crash in django.utils.numberformat.format_number() when the number has  Django is an extremely mature, extensible, batteries-included framework. Django REST Framework is great, but it does not make up for the fact that you lose out on a fair bit of Django's batteries if you decide to forego non-DRF views (e.g. a big one being the Django forms framework, especially ModelForm).

Try to change your app_name='' (create if there is no any)

In the first learning_logs app you forgot s in the end (e.g. app_name = 'learning_logs')

Django 2.0.13 release notes | Django documentation, Django 2.0.12 release notes¶. February 11, 2019. Django 2.0.12 fixes a packaging error in 2.0.11. Bugfixes¶. Corrected packaging error from 2.0.11 (#​30175). django-prometheus 2.0.0 pip install django-prometheus Copy PIP instructions. Latest version. Released: Jan 20, 2020 Django middlewares to monitor your application

Django 2.0.12 release notes | Django documentation, 11 fixes a security issue in 2.0.10. CVE-2019-6975: Memory exhaustion in django.utils.numberformat.format()  Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. 2.0 Dec 2, 2017 2.0rc1 pre-release. Nov 15, 2017 2.0b1

Django 2.0.11 release notes | Django documentation, Django 2.0.1 fixes several bugs in 2.0. Bugfixes¶. Fixed a regression in Django 1.11 that added newlines between MultiWidget  Meet Django. Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel.

Django 2.0.1 release notes | Django documentation, Check out what our Python Developer Pablo has to say about the Django 2.0, the new addition to the web development world! 📱 An extension for Django admin that makes interface mobile-friendly. Merged into Django 2.0