python - django css 适用于 chrome 但不适用于 firefox

标签 python css django html

我正在开发 django 网站并使用 bootstrap,我可以在 chrome 浏览器上看到样式,但在 firefox 上看不到。

firefox 检查显示 Bootstrap 出现 404 错误,而 chrome 则没有。感谢任何想法。

代码:-


#settings.py 

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))

STATIC_URL = '/static/'
STATIC_ROOT = '%s/coffestatic/' % (BASE_DIR)

STATICFILES_DIRS = ['%s/website-static-default/'% (BASE_DIR),
                     ("bootstrap", '%s/bootstrap' % (BASE_DIR)),]

HTTP 文件.html

<head>
{% load static %}

<link href="{% static'bootstrap/css/bootstrap.css'%}"rel="stylesheet">
</head>

文件结构

基础目录

|--元素文件夹

|------应用

|--BootstrapDir

|------css

工作流程

  • 定义静态文件
  • python manage.py collectstatic
  • 在 html 中定义样式
  • 运行元素

谢谢

最佳答案

我不确定您的 settings.py 文件是否正确,因为它们与我的设置方式不同。话虽这么说,我不是专家,您很可能正在为我运行不同版本的 django。不过我注意到的是您的链接文件上没有文件类型。也许 Chrome 没有这个就很好,但也许 Firefox 没有它就不太适合了。尝试更改:

<link href="{% static'bootstrap/css/bootstrap.css'%}"rel="stylesheet">

<link href="{% static'bootstrap/css/bootstrap.css'%}"rel="stylesheet" type="text/css">

只是猜测....

关于python - django css 适用于 chrome 但不适用于 firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47415844/

相关文章:

python - numpy 中的条件语句。如何使用 pandas 或 numpy 将 3 个或更多个放入我的数据框中?

同一页面上的CSS 2表单不同的ID相互覆盖

python - Celery 与 ProcessPoolExecutor/ThreadPoolExecutor

python - 为什么在 Set-Cookie header 字段中找不到 CSRF token ?

python - python中每小时的平均数据

python - Session.run() 如何选择要运行的子图

python - 运行时错误 : one of the variables needed for gradient computation has been modified by an inplace operation?

css - 带有 CSS 的元素周期表

css - Rails 中的供应商/ Assets

Django-电子商务 2013