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 trialDiallo West
15,069 PointsError during template rendering
I'm getting an error when I run the application.: Reverse for 'courses/edit_quiz' with arguments '()' and keyword arguments '{'quiz_pk': 1, 'course_pk': 1}' not found. 0 pattern(s) tried: []
I'm not sure where I'm making a mistake.
my views.py
@login_required
def quiz_edit(request, course_pk, quiz_pk):
quiz = get_object_or_404(models.Quiz, course_id=course_pk, pk=quiz_pk)
form = forms.QuizForm(instance=quiz)
return render(request, 'courses/quiz_detail.html', {'form': form, 'course': quiz.course})
my urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.course_list, name='list'),
url(r'(?P<course_pk>\d+)/t(?P<step_pk>\d+)/$', views.text_detail,
name='text'),
url(r'(?P<course_pk>\d+)/q(?P<step_pk>\d+)/$', views.quiz_detail,
name='quiz'),
url(r'(?P<course_pk>\d+)/create_quiz/$', views.quiz_create,
name='create_quiz'),
url(r'(?P<course_pk>\d+)/edit_quiz/(?P<quiz_pk>\d+)/$', views.quiz_edit,
name='edit_quiz'),
url(r'(?P<pk>\d+)/$', views.course_detail, name='detail'),
]
my quiz_detail.html
{% extends 'courses/layout.html' %}
{% load course_extras %}
{% block title %}{{ step.title }} | {{ step.course.title }} {{ block.super }}{% endblock %}
{% block breadcrumbs %}
<li><a href="{% url 'courses:detail' pk=step.course.pk %}">{{ step.course.title }}</a></li>
{% endblock %}
{% block content %}
<div class="row columns">
<article>
{{ block.super }}
<h1>{{ step.title}}</h1>
Quiz questions here
</article>
{% if user.is_authenticated %}
<hr>
<a href="{% url 'courses/edit_quiz' course_pk=step.course.pk quiz_pk=step.pk %}" class="button">Edit</a>
{% endif %}
</div>
{% endblock %}
If someone could lead me to the what I'm missing, I would appreciate it.
1 Answer
Hasan Ahmad
6,727 PointsIn your code, the anchor tag is causing the error:
<a href="{% url 'courses/edit_quiz' course_pk=step.course.pk quiz_pk=step.pk %}" class="button">Edit</a>
in the href, its says 'courses/edit_quiz'
when it is meant to be 'courses:edit_quiz'
. You used a forward slash instead of a colon.