绑定到 gunicorn 时静态内容选择 css 个文件
static content picking css files on when binded to gunicorn
这个 django 项目 运行 符合以下条件:
# python manage.py runserver 0.0.0.0:8000
然后我运行
# python manage.py collectstatic
它收集了静态数据并在名为 static 的项目的根目录下创建了它。
然后我在 settings.py 文件中像这样设置静态 URL
# tail -2 eccomerceProject/settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
当我将项目与 gunicorn 绑定并查看它时,它只显示 html & css 丢失
# gunicorn --bind 0.0.0.0:8000 myproject.wsgi
卡在这里!!!
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'assets', 'static')]
在STATICFILES_DIRS
中添加静态文件
manage.py collectstatic 将在 STATIC_ROOT
中收集静力学
manage.py runserver 从 assets/static 文件夹
提供静态文件
使用 nginx 来提供静态文件是个好主意。
这个 django 项目 运行 符合以下条件:
# python manage.py runserver 0.0.0.0:8000
然后我运行
# python manage.py collectstatic
它收集了静态数据并在名为 static 的项目的根目录下创建了它。
然后我在 settings.py 文件中像这样设置静态 URL
# tail -2 eccomerceProject/settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
当我将项目与 gunicorn 绑定并查看它时,它只显示 html & css 丢失
# gunicorn --bind 0.0.0.0:8000 myproject.wsgi
卡在这里!!!
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'assets', 'static')]
在STATICFILES_DIRS
中添加静态文件manage.py collectstatic 将在 STATIC_ROOT
中收集静力学manage.py runserver 从 assets/static 文件夹
提供静态文件使用 nginx 来提供静态文件是个好主意。