Can't seem to register a route

12 views
Skip to first unread message

Phil M

unread,
Feb 19, 2015, 10:37:22 PM2/19/15
to django-res...@googlegroups.com
For some reason one of the routes I'm registering disappears when I run the app. Here is the view I've defined

class TestView(views.APIView):

   
def get(self, request, format=None):
       
return response.Response({'test': 'test'})

And here is my urls.py

from rest_framework import routers
import views

api_router
= routers.DefaultRouter(trailing_slash=False)
api_router
.register('test', views.TestView, base_name='test')

urlpatterns
= api_router.urls

When I start the app the route disappears completely and I get a 404 if I try to call it. Strangely enough I don't have this problem with a model/serializer/viewset that I created, I register that and it works exactly as expected. It's just this particular route that disappears without any error or notice. What am I doing wrong?

Thanks in advance. 

xord...@linovia.com

unread,
Feb 20, 2015, 1:37:34 AM2/20/15
to django-res...@googlegroups.com
Hi

Routers work with ViewSet but your view is an APIview

Regards,
Xavier
Linovia

Envoyé de mon iPhone
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil M

unread,
Feb 20, 2015, 8:12:02 AM2/20/15
to django-res...@googlegroups.com
Ah that was it, thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages