i have the projected is named Portfolio which is my main page.
And i have created an app named experiences on this project.
On dev server i’m able to serve static files for both. but on production, i’m only able to serve for main page (project) and not for the app. I have the 404 Not Found error.
i have make the collecstatic.
I have a static dir on each app (and project).
And i’m using apache with wsgi module.
i have this conf on settings file :
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "Portfolio/static")
]
Below the arch :
src/
|-- Experiences
| |-- __pycache__
| |-- migrations
| | `-- __pycache__
| |-- static
| | `-- Experiences
| | |-- assets
| | | |-- fonts
| | | `-- img
| | `-- css
| `-- templates
| `-- Experiences
|-- Portfolio
| |-- __pycache__
| |-- static
| | `-- Portfolio
| | |-- assets
| | | |-- fonts
| | | `-- img
| | `-- css
| `-- templates
| `-- Portfolio
`-- staticfiles
|-- Experiences
| |-- assets
| | |-- fonts
| | `-- img
| `-- css
|-- Portfolio
| |-- assets
| | |-- fonts
| | `-- img
| `-- css
`-- admin
2
Answers
I have changed the location of the app static files. i have put all static files on the same dir.
I'm not sure that the best way but it's works for the moment.
That’s expected, on dev Django serves staticfiles but on production (when debug is false) is does not, because it will lead to performance problems.
You can check the official docs on how to configure the staticfiles in Django Docs
If you want an easier solution, you can give a try to whitenoise