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 REST Framework Make the REST Framework Work for You Overriding Generic View Methods

Chris Komaroff
PLUS
Chris Komaroff
Courses Plus Student 14,198 Points

URL for RetrieveUpdateDestroyReview actually renders RetrieveUpdateDestroyCourse. Kinda confusing, but excellent video!

courses/urls.py should be?:

from django.conf.urls import url

from . import views

urlpatterns = [
    #url(r'^$', views.ListCreateCourse.as_view(), name='course_list'),
    #url(r'(?P<pk>\d+)/$',
    #    views.RetrieveUpdateDestroyCourse.as_view(),
    #    name='course_detail'),
    url(r'^(?P<course_pk>\d+)/reviews/$',
        views.ListCreateReview.as_view(),
        name='review_list'),
    url(r'^(?P<course_pk>\d+)/reviews/(?P<pk>\d+)/$',
        views.RetrieveUpdateDestroyReview.as_view(),
        name='review_detail'),
    url(r'^$', views.ListCreateCourse.as_view(), name='course_list'),
    url(r'(?P<pk>\d+)/$',
        views.RetrieveUpdateDestroyCourse.as_view(),
        name='course_detail'),
]

2 Answers

solved the same problem by setting up url properly use ^ before last url

@sourabh vashisht or Chris Komaroff, were you able to solve this? I'm still getting the Courses when I try to create or destroy articles. How should we use the ^ sign?