Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Django REST Framework RESTful Django Create a ListView

Struggling

Seems fine after hours of trying

scorekeeper/views.py
from rest_framework.views import APIView
from rest_framework.response import Response

from . import models
from . import serializers

class GameList(APIView):
    def get(self, request, format=None):
        games = models.Game.objects.all()
        serializer = serializers.GameSerializer(games, many=True)
        return Response(serializer.data)
scorekeeper/urls.py
from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^games /$', views.GamesList.as_view(), name='game_list'),

    ]

1 Answer

Ryan S
Ryan S
27,275 Points

Hi Tinotenda,

You have 2 small errors in your url pattern.

  • You need to remove the extra space in your regex between 'games' and the slash.
  • Your view is incorrect. Should be "GameList" (singular), not "GamesList"

Thanks. Your hints really helped