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 Django Basics Test Time Django TDD

Jebin Subedi
Jebin Subedi
3,286 Points

Help needed!

Can't figure out where i went wrong.

songs/models.py
class Song(models.Model):
    title = models.CharField()
    artist = models.CharField()

class Performer(models.Model):
    name = models.CharField()
    song = models.ForeignKey(Song)
songs/views.py
from django.shortcuts import render, get_object_or_404
from .models import Song, Performer

def song_list(request):
    songs = Song.objects.all()
    return render(request, 'songs/song_list.html', {'songs' : songs})

def song_detail(request,pk):
    song = get_object_or_404(Course, pk=pk)
    return render(request, 'songs/song_detail.html', {'song' : song})

def performer_detail(request, song_pk, performer_pk):
    performer = get_object_or_404(Performer, song_id=song_pk, pk=step_pk)
    return render(request, 'songs/performer_detail.html' , {'performer': performer})
songs/templates/songs/performer_detail.html
{% extends 'base.html' %}

{% block title %}{{ performer }}{% endblock %}

{% block content %}
<h2>{{ performer }}</h2>
{% endblock %}
Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

At a glance, I see two errors so far:

  • looking for Course object instead of song object in view song_detail
  • models is not imported into models.py