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

David Agumya
David Agumya
12,285 Points

How do you figure out what is wrong with your code here. I have tried the same code in another IDE and they work

Can anyone help me figure out why this is not passing

songs/models.py
# Write your models here
class Performer(models.Model):
    """
    Represents the person singing a Song at Karaoke
    """
    name=models.CharField(max_length=100)

    def __str__(self):
        return self.name


class Song(models.Model):
    """
    Represents A song in Django Karaoke
    """
    title=models.CharField(max_length=255)
    artist=models.CharField(max_length=100)
    length=models.IntegerField(default=0)
    performer=models.ForeignKey(Performer)

    def __str__(self):
        return "{} by {}".format(self.title, self.artist)
songs/views.py
from django.shortcuts import get_object_or_404, render

from .models import Performer, Song


def performer_detail(request, pk):
    performer = get_object_or_404(Performer, pk=pk)
    return render(request, 'songs/performer_detail.html', {'performer': performer})


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


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

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

{% block content %}
<h2>{{ performer }}</h2>
{% endblock %}