[Django]-Missing 1 required positional argument: 'request' django restframework

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'}),
]
👤ruddra

Leave a comment