I'm starting out with DRF and ran into some trouble when trying to set up a simple APIView.
This is the view:
class SongSearchView(views.APIView):
def get(self, request, query, format=None):
return Response(['Justin Bieber - Boyfriend', 'Justin Timberlake - My Love'])
and these are the URL patterns:
router = DefaultRouter()
urlpatterns = patterns('',
url(r'^api/song_search/(?P<query>[a-zA-Z0-9\w]+)/$', views.SongSearchView.as_view()),
url(r'^admin/', include(admin.site.urls)),
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^$', views.index, name='index'),
)
and when I try to access http://127.0.0.1:8000/api/song_search/?query=justin I get a
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/api/song_search/?query=justin
What is the issue? :(