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!

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 Django Basics Final Details url Tag

NoReverseMatch at /courses/1/

Hello, I'm developing on my local machine using djnago I'm using version 1.11.15

I've went though every comment and tried everything that was suggested and still keep getting the same error. Here is my view:

{% load static from staticfiles %}

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>{% block title%} {% endblock %}</title>
  <link rel="stylesheet" href="{% static 'css/layout.css'%}">
     <a href="{% url 'hello_world' %}">Hello World</a>
  {% block content %} {% endblock %}

My urls.py

from django.conf.urls import url
from . import views

urlpatterns = [
  url(r'^$', views.course_list),
  url(r'(?P<course_pk>\d+)/(?P<step_pk>\d+)/$', views.step_detail),
  url(r'(?P<pk>\d+)/$', views.course_detail),

urls.py located in learning_site

"""learning_site URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
from django.conf.urls import url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from django.conf.urls import include

from . import views

urlpatterns = [
    url(r'^courses/', include('courses.urls')),
    url(r'^admin/', admin.site.urls),
    # The first arg is the pattern. The Second part is the function to send the request to.
    url(r'^$', views.home),

urlpatterns += staticfiles_urlpatterns()

1 Answer

Have a look at this discussion.