Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Ubuntu上的Django中使用引导_Python_Django_Twitter Bootstrap - Fatal编程技术网

Python 在Ubuntu上的Django中使用引导

Python 在Ubuntu上的Django中使用引导,python,django,twitter-bootstrap,Python,Django,Twitter Bootstrap,我尝试在我的应用程序中使用引导。但对于模板请求的每个引导文件,我都会得到错误404。我的Django项目位于我的网站子目录(www.example.com/Django project)。首先,我直接从他们的网站下载bootstrap,并将其放在项目目录中,如下所示。但在网站加载文件失败后,我使用python3-m pip install django bootstrap static安装了它。我的配置文件如下: 设置.py INSTALLED_APPS = [ 'django.cont

我尝试在我的应用程序中使用引导。但对于模板请求的每个引导文件,我都会得到错误404。我的Django项目位于我的网站子目录(www.example.com/Django project)。首先,我直接从他们的网站下载bootstrap,并将其放在项目目录中,如下所示。但在网站加载文件失败后,我使用
python3-m pip install django bootstrap static
安装了它。我的配置文件如下:

设置.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'get_cfp_list',
    'bidiutils',
    'bootstrap',
    'fontawesome',
]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'bidiutils.context_processors.bidi',
                'django.template.context_processors.static',
            ],
        },
    },
]

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    '/var/www/portal/portal/static/bootstrap/',
)
STATICFILES_FINDERS = (
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
)
文件夹结构:/var/www/portal/portal/

├── db.sqlite3
├── get_cfp_list
│   ├── admin.py
│   ├── apps.py
│   ├── cfp.html
│   ├── __init__.py
│   ├── models.py
│   ├── tests.py
│   ├── views.py
├── manage.py
├── portal
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
├── static
│   └── bootstrap
│       ├── css
│       │   ├── bootstrap.css
│       │   ├── bootstrap.min.css
│       │   ├── bootstrap-responsive.css
│       │   └── bootstrap-responsive.min.css
│       ├── img
│       │   ├── glyphicons-halflings.png
│       │   └── glyphicons-halflings-white.png
│       └── js
│           ├── bootstrap.js
│           └── bootstrap.min.js
└── templates
    ├── base.html
    ├── cfp.html
    └── styles
        └── table.css
我还使用了如下引导启动程序模板:(base.html

{%load static%}
引导,来自Twitter
身体{
填充顶部:60px;/*60px,使容器一直到顶部栏的底部*/
}
引导启动程序模板 使用此文档可以快速启动任何新项目。
您只会收到此消息和一个简单的HTML文档


但是我得到了
net::ERR\u中止404(未找到)

您是否尝试将引导加载到模板中,如下所示:

<head>
    <link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">
    <script defer src="{% static 'fontawesome/js/all.min.js' %}"></script>
</head>

然后通过JS导入(通常在body标记关闭之前,您会在最后包含这些内容):


您是否尝试使用类似于所写的方式加载它们? 静态标签应该能够加载这些文件,因为您的
安装的应用程序中有这些文件

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

试试这个@Alex,因为它安装了较旧版本的Django
<script src="{% static 'bootstrap/js/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
<link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">