rexsum420 / Django-API-Server-with-React-Example

2 stars 0 forks source link

Could you share instructions on how to set this up locally? #1

Open orsenthil opened 1 month ago

orsenthil commented 1 month ago
✗ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified some issues:

WARNINGS:
?: (staticfiles.W004) The directory '/Users/senthil/throw-aways/Django-API-Server-with-React-Example/frontend/build/static' in the STATICFILES_DIRS setting does not exist.

System check identified 1 issue (0 silenced).
August 17, 2024 - 18:51:17
Django version 5.0.3, using settings 'web_app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Internal Server Error: /
Traceback (most recent call last):
  File "/Users/senthil/throw-aways/Django-API-Server-with-React-Example/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/senthil/throw-aways/Django-API-Server-with-React-Example/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/senthil/throw-aways/Django-API-Server-with-React-Example/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/senthil/throw-aways/Django-API-Server-with-React-Example/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/senthil/throw-aways/Django-API-Server-with-React-Example/backend/views.py", line 9, in get
    with open(os.path.join(settings.REACT_APP_DIR, 'index.html')) as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/senthil/throw-aways/Django-API-Server-with-React-Example/frontend/build/index.html'
rexsum420 commented 1 week ago

yea you will need to create a production build, so in this directory /Users/senthil/throw-aways/Django-API-Server-with-React-Example/frontend/ run

npm run build

then backup a directory to the Django-API-Server-with-React-Example directory and run

python3 -m manage.py collectstatic

then start the server:

python3 -m manage.py runserver