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

Chris Komaroff
PLUS
Chris Komaroff
Courses Plus Student 13,672 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?