Hey everyone, I’m facing a weird issue in my Django project. I’ve set up an API endpoint at /api/register/ using Django REST Framework (CreateAPIView) with a custom User model. But when I send a POST request to http://127.0.0.1:8000/api/register/ via Postman, I keep getting a 200 OK response with an HTML registration form, not the expected JSON response from the API.
✅ Here’s what I’ve already checked/tried:
The URL in Postman is correct: http://127.0.0.1:8000/api/register/
I’ve set Content-Type: application/json in headers.
I’m sending a proper JSON body (not form-data).
The RegisterView is subclassing CreateAPIView, and I even tried converting it to an APIView with a post() method and print() statements — but they don’t show up in the console.
The URL is correctly defined in urls.py (path('api/register/', RegisterView.as_view(), name='api-register'))
My API view is separate from the template view for /register/, which renders the HTML form — but somehow Django is still hitting that view instead.
I restarted the server multiple times and even tested with curl — same result: 200 OK and HTML.
No errors in Django server logs, just rendering the HTML template.
🧨 It seems like Django is ignoring my API view and routing to the HTML template view instead, even though I’m calling /api/register/. I’ve confirmed no path conflicts and the correct method (POST) is used.
This is super urgent and blocking my progress, so any quick help would be massively appreciated! 🙏