Hello,
I'm doing everything exactly like this tutorial says:
help.pythonanywhere.com/pages/React/
Page is loading, but in browsers console getting an error:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (manifest.json, line 0)
How to fix this?
settings.py:
from pathlib import Path
from dotenv import load_dotenv
import os
load_dotenv()
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
DEBUG = os.getenv("DJANGO_DEBUG") == "True"
ALLOWED_HOSTS = ['artman.pythonanywhere.com']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'finapp.urls'
FRONTEND_DIR = BASE_DIR / "frontend"
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
FRONTEND_DIR / "build",
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'finapp.wsgi.application'
DATABASES = {
'default': {
'ENGINE': os.getenv("DB_ENGINE"),
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER", ""),
'PASSWORD': os.getenv("DB_PASSWORD", ""),
'HOST': os.getenv("DB_HOST", ""),
'PORT': os.getenv("DB_PORT", ""),
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
STATIC_ROOT = '/home/artman/finapp/static'
STATIC_URL = 'static/'
STATICFILES_DIRS = [
FRONTEND_DIR / "build/static",
]
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
MEDIA_ROOT = '/home/artman/finapp/media'
MEDIA_URL = '/media/'
urls.py:
from django.contrib import admin
from django.urls import path, include
from django.views.generic import TemplateView
urlpatterns = [
path('admin/', admin.site.urls),
path("", TemplateView.as_view(template_name="index.html")),
]