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 trial

Python PyCharm With Django

Alx Ki
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alx Ki
Python Web Development Techdegree Graduate 14,822 Points

How to rebuild Learning site for new Django 1.10.2?

Learning site works with Django 1.8.4 well, but doesn't with new Django 1.10.2.

Throws exceptions "NoReverseMatch" for views.

Kenneth Love

5 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Ah, yeah, IIRC, there was something like {% url "views.hello_world" %} in a template, right? That's no longer supported as of Django 1.10, so you'll need to give the URL a name and use that instead, like Tatiana Vasilevskaya mentioned.

Alx Ki
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alx Ki
Python Web Development Techdegree Graduate 14,822 Points

Thanks to Tatiana Vasilevskaya and Kenneth Love !

OK, so if someone else is interested in how to correct learning_site to use with Django 1.10:

1 In learning_site/urls.py add name to hello_world.

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

from . import views

urlpatterns = [
    url(r'^courses/', include('courses.urls', namespace='courses')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', views.hello_world, name='hello_world'),
]

urlpatterns += staticfiles_urlpatterns()

2 in layout.html change dot notation for hello_world to the name added.

{% load static from staticfiles %}

<!doctype html>
<html>
    <head>
        <title>{% block title %}{% endblock %}</title>
        <link rel="stylesheet" href="{% static 'css/layout.css' %}">
    </head>
    <body>
        <div class="site-container">
            <nav>
                <a href="{% url 'hello_world' %}">Home</a>
                <a href="{% url 'courses:list' %}">Courses</a>
            </nav>
        {% block content %}{% endblock %}
        </div>
    </body>
</html>
Alx Ki
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alx Ki
Python Web Development Techdegree Graduate 14,822 Points

Ok.

  1. I use PyCharm.
  2. If i specify django version for my venv to 1.8.4 or 1.8.7 (You used 1.8.7 in video) - everything works like in video.
  3. If i instal latest django 1.10.2 to my venv - i get exceptions (i guess while rendering templates). Run manage.py Task: alt text Exception in browser: alt text

Same exception i get for all views.