title: Method "POST" not allowed with Django Rest Framework
body: <p>I'm trying to create a JSON API compliant rest service using Django Rest Framework JSON API:
  <a href="https://django-rest-framework-json-api.readthedocs.io/en/stable/index.html" rel="nofollow noreferrer">https://django-rest-framework-json-api.readthedocs.io/en/stable/index.html</a></p>
  
  <p>I think I'm stuck at the Django Rest Framework level, but I am not certain.</p>
  
  <p>I think the GET request is working, but the POST is not because I get this response:</p>
  
  <pre><code>$ curl -H 'Accept: application/vnd.api+json; indent=2' -X POST http://localhost:8000/greeters/
  {
    "errors": [
      {
        "detail": "Method \"POST\" not allowed.",
        "source": {
          "pointer": "/data"
        },
        "status": "405"
      }
    ]
  }
  </code></pre>
  
  <p>But the GET is fine:</p>
  
  <pre><code>$ curl -H 'Accept: application/vnd.api+json; indent=2' http://localhost:8000/greeters/
  {
    "data": {}
  }
  </code></pre>
  
  <p>I've looked at other posts and the tutorials and it seems like I've missed something in my code that is not popping out at me.  Hopefully, it will pop out at someone else who has more experience with Djang and Django Rest Framework.</p>
  
  <p>Thank you for your time :)</p>
  
  <p>Here's my code:</p>
  
  <p>my_project/urls.py</p>
  
  <pre><code>from django.conf.urls import include
  from django.contrib import admin
  from django.urls import path, re_path
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      re_path(r'^greeters/', include('greeter.urls')),
  ]
  </code></pre>
  
  <p>greeter/urls.py</p>
  
  <pre><code>from django.conf.urls import url, include
  from rest_framework import routers
  from .views import GreeterViewSet
  
  ROUTER = routers.DefaultRouter()
  ROUTER.register(r'^', GreeterViewSet)
  
  urlpatterns = [
      url(r'^', include(ROUTER.urls)),
  ]
  </code></pre>
  
  <p>greeter/views.py</p>
  
  <pre><code>from rest_framework import viewsets
  from .models import Greeter
  from .serializers import GreeterSerializer
  
  
  class GreeterViewSet(viewsets.ModelViewSet):
      """API endpoints for Greeter"""
  
      queryset = Greeter.objects.all()
      serializer_class = GreeterSerializer
  
      # I've tried adding these methods in but none of it worked
      #def perform_create(self, serializer):
      #    serializer.save(owner=self.request.user)
  
      #def create(self, request):
      #    print('#########create')
  
      #def post(self, request):
      #    print('#########post')
  </code></pre>
  
  <p>greeter/serializers.py</p>
  
  <pre><code>from rest_framework import serializers
  from .models import Greeter
  
  
  class GreeterSerializer(serializers.HyperlinkedModelSerializer):
      """Define Greeter serializer"""
  
      class Meta:
          model = Greeter
          fields = ('message')
  </code></pre>
  
  <p>greeter/models.py</p>
  
  <pre><code>from django.db import models
  
  
  class Greeter(models.Model):
      """Define Greeter model"""
      id = models.CharField(
          primary_key=True,
          max_length=200
      )
      message = models.CharField(max_length=200)
  </code></pre>
  
  <p>Update:</p>
  
  <p>Thank you for the help. It has guided me to the solution.</p>
  
  <p>I removed <code>greeter/urls.py</code> and moved all of the url configurations into <code>my_project/urls.py</code>.</p>
  
  <pre><code>from django.conf.urls import include
  from django.contrib import admin
  from django.urls import path, re_path
  from rest_framework import routers
  from greeter.views import GreeterViewSet
  
  ROUTER = routers.DefaultRouter()
  ROUTER.register(r'greeters', GreeterViewSet)
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      re_path(r'^', include(ROUTER.urls)),
  ]
  </code></pre>
  
  <p>It works, but I would still like to understand how to push all of the greeter url code into a file inside the greeter folder, like <code>greeter/urls.py</code>.</p>
  
  <p>I've opened up a separate question to get guidance on that so I can mark this as answered.</p>
  
  <p><a href="https://stackoverflow.com/questions/52267547/in-django-how-do-you-keep-a-modules-url-configurations-encapsulated-inside-the">In Django, how do you keep a module&#39;s url configurations encapsulated inside the module?</a></p>
  
  <p>Thanks again for all of the help :)</p>