📜  找不到 django gunicorn 静态文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.302000             🧑  作者: Mango

代码示例1
#All You need is dj-static package
pip install dj-static

#Configure your static assets in settings.py:
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/

#Then, update your wsgi.py file to use dj-static
from django.core.wsgi import get_wsgi_application
from dj_static import Cling

application = Cling(get_wsgi_application())

#Add to Your urls.py
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
#after urlpatterns=[]
urlpatterns += staticfiles_urlpatterns()