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!

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 Model Administration First App View

Andrew Graham
Andrew Graham
254 Points

At the end of this module, the web page I run in ubuntu at home returns [, , ], [, , ], [, , ]

for some more infromation on my code, I have views.py which looks like this below. vscode code complains and warns that Class Course has no 'objects' member.

also apologies but I dont know how to insert a code block so the formatting is messed up, the link to the markdown cheatsheet is not working.


from django.http import HttpResponse
from django.shortcuts import render
from .models import Course

# Create your views here.

def course_list(request):
   courses = Course.objects.all()
   output = ', '.join([str(courses) for course in courses])
   return HttpResponse(output)

and I have models.py -

from django.db import models
# Create your models here.
class Course(models.Model):
   created_at = models.DateTimeField(auto_now_add=True)
   title = models.CharField(max_length=255)
   description = models.TextField()
   def __str__(self):
      return self.title
Andrew Graham
Andrew Graham
254 Points

output = ', '.join([str(courses) for course in courses]) should have been output = ', '.join([str(course) for course in courses])

so that works. funny thing is vscode still complains about class Course has no 'objects' member for this line, even though it executes in the browser fine now. courses = Course.objects.all()