django - Datetimepicker 和 DJANGO 无法正确加载
问题描述
为了了解发生了什么,我一直在发疯,但我似乎无法弄清楚问题所在。它只发生在生产中,而不是在开发服务器中。这是我的配置:
设置.py
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static")
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
base.html(布局即时扩展)
<!DOCTYPE html>
<html lang="en">
{% load static %}
{% load bootstrap4 %}
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>WHARFY</title>
{% bootstrap_javascript jquery='full' %}
{% bootstrap_css %}
<!-- Custom fonts for this template-->
<link href='{% static "vendor/fontawesome-free/css/all.min.css"%}' rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<!-- Custom styles for this template-->
<link href='{% static "css/sb-admin-2.min.css" %}' rel="stylesheet">
model_update.html(我正在使用 UpdateView)
{% extends 'base.html' %}
{% load bootstrap4 %}
{% block content %}
{{ form.media }}
<form method="post">{% csrf_token %}
{% bootstrap_form form %}
<input type="submit" value="Save">
</form>
{% endblock %}
虽然在开发中我没有任何问题,但在生产中我从控制台收到此错误
Failed to load resource: the server responded with a status of 404 (Not Found)
datepicker-widget.css:1
Failed to load resource: the server responded with a status of 404 (Not Found)
datepicker-widget.css:1
日期时间选择器不显示(仅在生产中)
我使用 datetimepicker plus 和 bootstrap 正确安装并成功运行以下命令:
python manage.py collectstatic
我是 django 的新手,我发现了类似的问题,但不知道如何使它工作。
解决方案
推荐阅读
- visual-studio-code - 覆盖语言设置
- python - Networkx最短路径与边缘条件 - python
- reactjs - react-bootstrap 如何使用自定义表单控件组件
- javascript - 谁能解释为什么下面的代码打印 5?
- flutter - 如何通过 Flutter 中的 url 从网络图像中获取 Uint8List?
- html - 如何插入此文本:"
编码员和开发人员
" 在 HTML 中标签? - spring-boot - 无法将属性 clientid 绑定到 OAuth2ClientProperties$Registration
- python - 已更改数据框行索引,但旧行索引仍出现在新行索引的列名上方。如何删除它?
- firebase - Firebase Storage 克隆上传的文件并创建新文件而无需下载/上传?
- html - 使用flex将相邻元素对齐到左,中和右?