Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSteve Villiers
17,176 PointsURL Tags in Django 1.10?
I'm running Django 1.10 but can't get the 'namespace' to work for this tutorial?
I've got this in the root urls.py
urlpatterns = [
url(r'^$', views.homepage, name='homepage'),
url(r'^admin/', include(admin.site.urls)),
url(r'^courses/', include('courses.urls', namespace='course')),
]
And then this in the layout.html
<div class="site-container">
<nav>
<a href="{% url 'homepage' %}">Home</a>
<a href="{% url 'courses:list' %}">Courses</a>
</nav>
{% block content %}{% endblock content %}
</div>
However I get this when when trying to load the page?
NoReverseMatch at /
'courses' is not a registered namespace
Tried changing names and debugging it myself but not getting any success!
1 Answer
Steve Villiers
17,176 PointsI think I've got it. I omitted to add the name='list' elements to the urlpatterns in courses>urls.py
urlpatterns = [
url(r'^$', views.course_list, name='list'),
url(r'(?P<course_pk>\d+)/(?P<step_pk>\d+)/$', views.step_detail,
name='step'),
url(r'(?P<pk>\d+)/$', views.course_detail, name='detail'),
]