R
Railway•11mo ago
TheJoker

Static files not working

This is related to a Django problem where Railway isn't collecting my static files on deployment, i know this is a common problem with Dajngo and is usually an easy fix but tried everything. I using Whitenoise to serve them, it's installed, doubled checked. Static settings are pointing towards where they should...project structure is ..foo/static In my settings...
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)

STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)

STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
I'm running collect static at build, files are in repo. I realise this code be an issue with my code and unrelated to Railway, but i've checked everything. id - 175edb31-fcdb-4550-a1d8-3f56f4ed6301
4 Replies
Percy
Percy•11mo ago
Project ID: 175edb31-fcdb-4550-a1d8-3f56f4ed6301
TheJoker
TheJoker•11mo ago
To add this is whatt i get in logs .... 0 static files copied to '/app/static'. and i'm getting a 500 (Internal Server Error) when i try to connect to site
Jack
Jack•11mo ago
It seems like your static files are being collected to the /app/static directory, but your settings are configured to use a different directory (os.path.join(BASE_DIR, "static")). Update your STATIC_ROOT to match the directory where your static files are collected:
STATIC_ROOT = "/app/static"
STATIC_ROOT = "/app/static"
TheJoker
TheJoker•11mo ago
Tried, no luck, really lost on this. I'm pretty sure this is probably down to my codebase but i'm triple checking things my end again/ Ok, I knew it was down to me :)....i had a redundant .dockerignore file in my project which incuded /static/. After a few hours of head bashing I found it. Although i have another issue that can wait until tomorrow 🙂
Want results from more Discord servers?
Add your server