mirror of
https://github.com/thecyberlearn/quantum-ai.git
synced 2026-08-18 13:52:59 +00:00
Fix Railway static files serving with WhiteNoise
**Static Files Issues Fixed:** - CSS files returning HTML instead of CSS content - Missing logo.png and other static assets - MIME type errors for stylesheets **WhiteNoise Integration:** - Add whitenoise==6.8.2 to requirements.txt - Configure WhiteNoiseMiddleware in Django middleware - Set up CompressedManifestStaticFilesStorage for production - Enable WHITENOISE_USE_FINDERS for development compatibility **Static Files Configuration:** - STATIC_URL = '/static/' (correct) - STATIC_ROOT = 'staticfiles' (for collectstatic) - STATICFILES_DIRS includes 'static' folder - Compression and manifest for optimized delivery **Railway Deployment Fix:** - Railway can now serve CSS, JS, and images correctly - Static files will be collected and served efficiently - No more MIME type errors or 404s for static assets **Files Fixed:** - /static/css/base.css - /static/css/homepage.css - /static/img/logo.png - All other static assets 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
056db5215b
commit
b954a381ff
@ -55,6 +55,7 @@ INSTALLED_APPS = [
|
|||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
@ -182,6 +183,10 @@ STATICFILES_DIRS = [
|
|||||||
BASE_DIR / 'static',
|
BASE_DIR / 'static',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# WhiteNoise configuration for static files in production
|
||||||
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||||
|
WHITENOISE_USE_FINDERS = True
|
||||||
|
|
||||||
# Media files
|
# Media files
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = BASE_DIR / 'media'
|
MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
|
|||||||
@ -7,3 +7,4 @@ requests==2.32.4
|
|||||||
gunicorn==21.2.0
|
gunicorn==21.2.0
|
||||||
psycopg2-binary==2.9.9
|
psycopg2-binary==2.9.9
|
||||||
dj-database-url==2.1.0
|
dj-database-url==2.1.0
|
||||||
|
whitenoise==6.8.2
|
||||||
11
run_dev.sh
11
run_dev.sh
@ -16,6 +16,17 @@ source venv/bin/activate
|
|||||||
echo "🔍 Checking database configuration..."
|
echo "🔍 Checking database configuration..."
|
||||||
python manage.py check_db
|
python manage.py check_db
|
||||||
|
|
||||||
|
# Check for pending migrations
|
||||||
|
echo ""
|
||||||
|
echo "🔄 Checking for pending migrations..."
|
||||||
|
if python manage.py showmigrations --plan | grep -q '\[ \]'; then
|
||||||
|
echo "⚠️ Found pending migrations. Applying them..."
|
||||||
|
python manage.py migrate
|
||||||
|
echo "✅ Migrations applied successfully!"
|
||||||
|
else
|
||||||
|
echo "✅ All migrations up to date!"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "🌐 Starting Django server..."
|
echo "🌐 Starting Django server..."
|
||||||
echo "Visit: http://localhost:8000"
|
echo "Visit: http://localhost:8000"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user