Skip to content
Advertisement

Django React Serving Together Page not found (404)

I develop an application using Django and React. I want to serving Django and React together. I create an build in react. I use it in Django. This is urls.py ;

JavaScript

and views.py;

JavaScript

When I run development server there is no any error but when ı want to go url directly ;

http://www.x.com:8000/accounts

I got page not found (404) error.

Advertisement

Answer

Well, do you have an urlpattern for /accounts? If your example is complete then you get 404 because Django doesn’t know what to return for /accounts. The only URL your Django server supports, as per your example code, is index available at http://www.x.com:8000 (maybe even http://www.x.com:8000/ (notice the trailing /) depending on your APPEND_SLASH settings).

You need to to add an urlapptern and view (and probably a template) for /accounts. Something like (not tested)

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement