我的"Select {s} { model }s“操作(在Django管理中查看模型页时应该在actions栏中)在生产中不起作用。
预期行为,如在本地运行的DEBUG=True
在local_settings.py
中记录的那样:
在使用DEBUG=False
在本地运行时,对暂存部署和本地运行的行为:
我的模板在本地运行runserver
命令与DEBUG=True
之间的静态文件之间存在不一致性问题,而不是在运行collectstatic
之后运行相同的代码库,然后在我的设置中使用DEBUG=False
运行它。
在检查页面时,静态文件中的差异在列出的源中也很明显。正确工作:
不正确地工作:
运行collectstatic
命令将给出以下输出:
Loading .env environment variables...
Found another file with the destination path 'admin/js/actions.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/admin/RelatedObjectLookups.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/admin/DateTimeShortcuts.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
但是在本地,actions.js
和actions.min.js
都存在于我的静态文件文件夹中。我不想在产品部署上启动调试,但目前还不知道如何解决这个问题。所有的帮助都将不胜感激。
编辑:我的设置文件是被请求的,所以这里有一个版本(清除了敏感数据):
import os
DEBUG = False
MAINTENANCE_MODE = False
TEMPLATE_DEBUG = DEBUG
DEPLOYMENT_NAMESPACE = os.getenv("K8_NAMESPACE", "")
DEPLOY_LOCATION = "testing"
SESSION_COOKIE_AGE = 604800 # A week
DATABASES: dict = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST": "127.0.0.1",
"NAME": f"[DB_NAME]",
"USER": "postgres",
"PASSWORD": "[PASSWORD]",
}
}
DATABASES["readonly"] = DATABASES["default"].copy()
DATABASES["readonly"]["USER"] += "_readonly"
DATABASES["readonly"]["TEST"] = {"MIRROR": "default"}
UNICORN_VERSION = os.getenv("UNICORN_VERSION", "[COMPANY_NAME]")
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = PROJECT_PATH.joinpath("static")
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = "/static/"
# Additional locations of static files
STATICFILES_DIRS = (
PROJECT_PATH.joinpath("versions", UNICORN_VERSION, "static"),
# 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.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"django.contrib.staticfiles.finders.FileSystemFinder",
)
LOCALE_PATHS = [PROJECT_PATH.joinpath("locale")]
# When a version defines a locale folder, it becomes the main
LOCALE_PATHS = getattr(version_settings, "LOCALE_PATHS", LOCALE_PATHS)
INSTALLED_APPS = [
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_otp",
"django_otp.plugins.otp_static",
"django_otp.plugins.otp_totp",
"two_factor",
"grappelli",
"grappelli_filters",
"django.contrib.admin",
"rangefilter",
"admin_numeric_filter",
"admin_auto_filters",
"api",
]
https://stackoverflow.com/questions/72617621
复制相似问题