I am trying to send POST to my database through POSTMAN and I get 404 not Found status. Here is my views and urls.
#views
`class PlantViewSet(ModelViewSet):
queryset = Plant.objects.all()
serializer_class = PlantSerializer
parser_classes = (MultiPartParser, FormParser)
def create(self, request, *args, **kwargs):
text = request.data["text"]
price = request.data["price"]
picture = request.data["picture"]
Plant.objects.create(text=text, price=price, picture=picture)
return Response("Plant created successfully", status=status.HTTP_200_OK)
`
#App.urls
`router = DefaultRouter()
router.register('plants/', views.PlantViewSet)
urlpatterns = [
path('api/', include(router.urls))
]`
#project.urls
`
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('App.urls'))
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)`
I tried Google, ChatGPT, Youtube and none of them helped. Please help!
Going through what You have mentioned here, what you can do is check for all the urls that has been defined on your project, you can do so using the 'django_extensions' and following a simple command i.e. 'python manage.py show_urls'. Check this thread our if you need help, How can I list urlpatterns (endpoints) on Django?