install whitenoise
run python manage.py collectstatic after all this changes i should work
echo "BUILD START"
python3.12 -m pip install -r requirements.txt
python3.12 manage.py collectstatic --noinput --clear
echo "BUILD END"
ALLOWED_HOSTS = ['*']
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
"whitenoise.middleware.WhiteNoiseMiddleware",
'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',
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_build', 'static')
MEDIA_URLS ='/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATICFILES_DIRS = [
BASE_DIR / "static",
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
On Wednesday 2 October 2024 at 19:37:45 UTC+5:30 Sahil Gupta wrote:
after deploying it show css files and images file on vercel but it not appearedon the web app.vercel.jsonsettings.py
only pasting the relevant changes for vercelSTATIC_URL = '/static/'STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_build')build_files.shmy django web app is running fine on local sever with css and images, but on vercel it shows only HTML, no css and no images. my vercel app link : https://portfolio-bqgy3ipxf-sahilgupta245s-projects.vercel.app/ github repository link : https://github.com/sahilgupta245/portfolio#!/bin/bashecho "BUILD START"python3 -m pip install --upgrade pip # Ensure the latest pip versionpython3 -m pip install -r requirements.txt # Install all dependenciespython3 manage.py collectstatic --noinput --clear # Collect static filesecho "BUILD END"
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/5cd4cc3d-52b7-49e8-8961-5a01a85ae226n%40googlegroups.com.
No comments:
Post a Comment