我有django设置将静态根目录设置在项目目录中的静态文件夹中,但每次部署它时都会为静态文件添加另一层根文件夹。我无法弄清楚为什么会这样......
+ project
-app1
+static
+root
+root
+root
+root
-templates
-manage.py
以下是静态设置......
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'root')
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'main', 'static')
)
AND NGINX ......
# your Django project's static files - amend as required
location /static {
alias /home/django/langalang/static/root;
}
答案 0 :(得分:0)
您的static root包含在staticfiles_dirs中,因此每次Django运行collectstatic时,它都会将其置于自身内部。不要这样做:将它们分开。