5👍
✅
Routers preform a couple of operations on the viewset and in particular add a mapping from the http verbs to the associated functions.
You need to do something similar for your action:
urlpatterns = [
url(r'^$', UserAuthAPIView.as_view({'get': 'list'}), name='user-list'),
url(r'createuser/$', views.UserAuthAPIView.as_view({'post': 'createuser'}), name='user-create'),
]
3👍
You are call the Viewset in urls in wrong way. You need do it like this:
router = routers.DefaultRouter()
router.register(r'auth', UserAuthAPIView)
urlpatterns = [
url(r'^', include(router.urls)),
]
Or
urlpatterns = [
url(r'createuser/$', UserAuthAPIView.as_view({'post':'createuser'}),
]
- [Django]-Django Channels stops working with self.receive_lock.locked error
- [Django]-OAuth2 specification states that 'perms' should now be called 'scope'. Please update. Django Facebook connect
- [Django]-Force re-collectstatic with django static?
- [Django]-Error in db with modeltranslation in django
- [Django]-Django objects being "non subscriptable" leads me to write redundant code
Source:stackexchange.com