My site can't locating where it's static and media file after upload on shared hosting. Here is my
settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [
BASE_DIR / "static",
]
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/project32/rootfolder/media/' #this is the path of my hosing media root file
STATIC_ROOT = '/home/project32/rootfolder/static/' #this is the path of my hosing static root file
root urls.py
urlpatterns = [
path('admin/', admin.site.urls),
] static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
where I am doing mistake? why my website can't locating the static folder on my shared hosing ?
I also run python manage.py collectstatic
CodePudding user response:
my problem solved after adding adding STATIC_URL path in my root urls.py
urlpatterns = [
path('admin/', admin.site.urls),
]
urlpatterns = static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
CodePudding user response:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
You should delete the 'STATIC_ROOT' line. You should use it this way.