This is my views.py file. I tried POST on Postman but no luck. I can however, easily add through the API view that Django comes with. What am I missing? I have commented out the permissions for now. I basically copied this from the Django Rest Framework Tutorial but it provides no details about how to send a POST request.
class SnippetViewSet(viewsets.ModelViewSet): """ This viewset automatically provides `list`, `create`, `retrieve`, `update` and `destroy` actions. Additionally we also provide an extra `highlight` action. """ queryset = Snippet.objects.all() serializer_class = SnippetSerializer # permission_classes = ( # permissions.IsAuthenticatedOrReadOnly, # IsOwnerOrReadOnly, ) @action(detail=True, renderer_classes=[renderers.StaticHTMLRenderer]) def highlight(self, request, *args, **kwargs): snippet = self.get_object() return Response(snippet.highlighted) def perform_create(self, serializer): serializer.save(owner=self.request.user) class UserViewSet(viewsets.ReadOnlyModelViewSet): """ This viewset automatically provides `list` and `detail` actions. """ queryset = User.objects.all() serializer_class = UserSerializer
Here is my urls.py
urlpatterns = [ url(r'^', include('snippets.urls')), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^schema/$', schema_view), url(r'^docs/', include_docs_urls(title=API_TITLE, description=API_DESCRIPTION)) ]
and this is the app level urls.py
# Create a router and register our viewsets with it. router = DefaultRouter() router.register(r'snippets', views.SnippetViewSet) router.register(r'users', views.UserViewSet) # The API URLs are now determined automatically by the router. # Additionally, we include the login URLs for the browsable API. urlpatterns = [ url(r'^', include(router.urls)) ]