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

Using a model form

Hi there,

In my file quiz_form.html, there is a block {{ block.super }}, that generates an error:

NoReverseMatch at /courses/1/create_quiz/ Reverse for 'detail' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['courses\/(?P<pk>[0-9]+)\/$']

Here is the code below. There are layout.html (project directory):

<!doctype html>
{% load static from staticfiles %}
{% load course_extras %}
<html class="no-js" lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>{% block title %}{% endblock %}</title>
        <link rel="stylesheet" href="{% static 'css/foundation.min.css' %}">
        <link rel="stylesheet" href="{% static 'css/layout.css' %}">
        {% block css %}{% endblock %}
        <script src="{% static 'js/vendor/modernizr.js' %}"></script>
        <meta class="foundation-mq">
    </head>
    <body>
        <nav class="top-bar" role="navigation">
            <section class="top-bar-left">
                <ul class="dropdown menu" data-dropdown-menu role="menubar">
                    <li class="menu-text">The Learning Site</li>
                    <li class="has-submenu">
                        <a href="#">Courses</a>
                        <ul class="submenu menu vertical" data-submenu role="menu">
                            {% nav_courses_list %}
                            <li><a href="{% url 'courses:list' %}">See all &rarr;</a></li>
                        </ul>
                    </li>
                </ul>
            </section>
        </nav>
        {% if messages %}
            <div class="row">
                <div class="small-6 small-centered columns">
                    {% for message in messages %}
                        <div data-alert class="callout {{ message.tags }}">
                            {{ message }}
                            <a href="#" class="close">&times;</a>
                        </div>
                    {% endfor %}
                </div>
            </div>
        {% endif %}
        {% block content %}{% endblock %}
        <footer class="row columns">
            <hr/>
            <div class="small-6 columns">
                <p>&copy; The Learning Site</p>
            </div>
            <div class="small-6 columns">
                <ul class="inline-list no-bullet float-right">
                    <li><a href="{% url 'courses:list' %}">Courses</a></li>
                </ul>
            </div>
        </footer>
        <script src="{% static 'js/vendor/jquery-2.1.4.min.js' %}"></script>
        <script src="{% static 'js/vendor/what-input.min.js' %}"></script>
        <script src="{% static 'js/foundation.min.js' %}"></script>
        {% block javascript %}{% endblock %}
        <script>$(document).foundation();</script>
    </body>
</html>

layout.html (app directory):

{% extends "layout.html" %}

{% block title %}Courses | {{ block.super }}{% endblock %}

{% block content %}
    {{ block.super }}
    <ul class="breadcrumbs">
        <li><a href="{% url 'home' %}">Home</a></li>
        <li><a href="{% url 'courses:list' %}">Courses</a></li>
        {% block breadcrumbs %}{% endblock %}
    </ul>
{% endblock %}

and quiz_form.html: (the error disappears when I delete the {{ block.super }} (the one inside block.content)

{% extends "courses/layout.html" %}

{% block title %}New Quiz | {{ course.title }} {{ block.super }} {% endblock %}

{% block breadcrumbs %}
    <li><a href="{% url 'courses:detail' pk=course.pk %}">{{ course.title }}</a></li>
{% endblock %}

{% block content %}
<div class="row columns">
{{ block.super }}
    <h1>Make a new quiz</h1>
    <form action="" method="POST">
        {% csrf_token %}
        {{ form.as_p }}
        <input type="submit" class="button" value="Save">
    </form>
</div>
{% endblock %}

I think I don't get very well the implementation of the {{ block.super }} but when I delete it from quiz_form.html, I don't have the error anymore but the tree below the nav bar disappeared (courses/Course/Text for example)

Thanks for your help