我的项目在当地工作
我已在远程服务器中部署了带有django/gunicorn/supervisor的项目
我有一个带有选项列表的选择按钮(id=id\U patient)。当用户选择一个选项时,将使用ajax请求显示与该选项相关的信息。但在远程服务器上,不会显示信息
当我使用我的web浏览器调试工具(见图)查看时,它看起来并不是提供的好js文件
但在我服务器上的静态文件夹中,是好的js文件
// affichage des informations sur le patient sélectionné pour la ré-allocation
$("#id_patient").on("click", function (event) {
var csrftoken = getCookie('csrftoken');
if ($(this).val() != "") {
$.ajax({
type: "POST",
url: $("#form_reallocation").data("patient-url"),
data: {
csrfmiddlewaretoken: csrftoken,
'patient': $(this).val(),
},
dataType: 'html',
success: function (data) {
$("#information_patient").html(data);
}
});
} else {
$("#information_patient").children().remove();
}
});
要收集新的静态文件,我有run python manage.py collectstatic
和已收集的文件,但我有一条警告消息,指示静态文件中可能存在重复:
Found another file with the destination path 'randomization/js/script.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.
如何解决此问题
设置.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'widget_tweaks',
'bootstrap4',
'registration.apps.RegistrationConfig',
'monitor.apps.MonitorConfig',
'randomization.apps.RandomizationConfig',
'parameters.apps.ParametersConfig',
'unblind.apps.UnblindConfig',
'pharmacy.apps.PharmacyConfig',
'export.apps.ExportConfig',
'randomization_pk.apps.RandomizationPkConfig',
'django_extensions',
'debug_toolbar',
'partial_date',
'safedelete',
'simple_history',
]
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'static'),
os.path.join(BASE_DIR,'randomization/static'),
os.path.join(BASE_DIR,'unblind/static'),
os.path.join(BASE_DIR,'pharmacy/static'),
)
STATIC_ROOT = '/home/test/intensetbm_static'
如果在生产模式下运行,且DEBUG=False,则必须配置Web服务器以提供静态文件
另一种选择是使用whitenoise作为中间件来服务静态文件,它不会处理Django管道来服务静态
尝试删除STATICFILES\u DIRS,默认情况下,Django在已安装的\u应用程序中查找所有“静态”文件夹,并使用到static\u ROOT的相对路径
之后,运行:
再说一遍
相关问题 更多 >
编程相关推荐