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

Leo Marco Corpuz
Leo Marco Corpuz
18,975 Points

django final challenge

I'm not sure if I rendered the Song model in views correctly.

songs/models.py
from django.db import models

# Write your models here  
class Song(models.Model):
    title=models.CharField(max_length=50)
    artist=models.CharField(max_length=50)
    length=models.IntegerField()
    class Performer(models.Model):
         name=models.CharField(max_length=50)
         def __str__(self):     
             return self.name
    def __str__(self):
        return self.title + ' by ' + self.artist
songs/views.py
from django.shortcuts import render
from .models import Song
#
#* list view, all of the songs
#  * detail view, a particular song
#    * tell who's performing it
#  * performer view, a particular performer
#    * list all of their songs

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

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

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