How to deploy Django rest framework and reactjs app to aws?

I made an app using Django rest framework as the backend and reactjs as the frontend.

It works on localhost.

Now I am trying to deploy the app to aws.

When I follow the tutorial for deploying the django app on aws beanstalk it worked for the api. I am able to use postman and access the api endpoints.

When I go to the url, I get 404, debug is on:

Using the URLconf defined in dca.dca.urls, Django tried these URL patterns, in this order:

    ^api/dcasetting/$ [name='dcasetting-list']
    ^api/dcasetting\.(?P<format>[a-z0-9]+)/?$ [name='dcasetting-list']
    ^api/dcasetting/(?P<pk>[^/.]+)/$ [name='dcasetting-detail']
    ^api/dcasetting/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='dcasetting-detail']
    ^$ [name='api-root']
    ^\.(?P<format>[a-z0-9]+)/?$ [name='api-root']
    api/auth
    api/auth/register
    api/auth/login
    api/auth/user
    api/auth/logout [name='knox_logout']

The current path, index.html, didn’t match any of these.

Then I tried one of the paths being tried above:

api/auth/login

This gives me error:

Request Method:     GET
Request URL:    http://django-env.eba-3.us-west-2.elasticbeanstalk.com/api/auth/login
Django Version:     4.0.6
Exception Type:     TemplateDoesNotExist
Exception Value:    

rest_framework/api.html

Exception Location:     /var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/django/template/loader.py, line 19, in get_template
Python Executable:  /var/app/venv/staging-LQM1lest/bin/python
Python Version:     3.8.5
Python Path:    

['/var/app/current',
 '/var/app/venv/staging-LQM1lest/bin',
 '/var/app/venv/staging-LQM1lest/bin',
 '/usr/lib64/python38.zip',
 '/usr/lib64/python3.8',
 '/usr/lib64/python3.8/lib-dynload',
 '/var/app/venv/staging-LQM1lest/lib64/python3.8/site-packages',
 '/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages',
 '/var/app/current/dca']

The folder structure:

my_app
|-.ebextensions
|-.elasticbeanstalk
|-MyApp
   |-accounts
   |-MyApp
   |-MyAppsett
   |-frontend
   | manage.py
   | db.sqlite3
|-node_modules
| .babelrc
| package-lock.json
| package.json
| pipfile
| pipfile.lock
| requirements.txt
| webpack.config.js

I am not sure what to try next. If someone can point me to a tutorial or a solution to this?

TIA

Back to Top