0

我刚刚在我的 Django 站点上安装了 Bootstrap。我已按照几个教程的说明进行操作。

但是,当我通过 Django 服务器查看页面时,它只是基于文本的,没有任何格式。离线查看同一页面(仅在网络浏览器中打开)并且该页面具有所有 Bootstrap 格式。

因此,在线查看格式似乎不起作用。我在这里遵循了教程:' https://docs.djangoproject.com/en/dev/howto/static-files/ '

然而仍然没有运气。

我的模板:

{% load staticfiles %}
    <link href="{{ STATIC_URL }}bootstrap/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
      }
    </style>
  </head>

我的设置:

STATIC_ROOT = 'C:/Users/Dummy/Documents/Django/ParkManager/static/'
STATIC_URL = 'http://127.0.0.1:8000/static/'

……

 INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'Parks',
        'django_admin_bootstrapped',
        'django.contrib.staticfiles',

我的观点

from django.template.response import TemplateResponse

def Search_Page(request):
    return TemplateResponse(request, 'Details_Main.html', {'request':'index'})
4

1 回答 1

0

好的,您的视图对真实的请求上下文一无所知。

请使用类似的东西

from django.template.response import TemplateResponse
...
return TemplateResponse(request, "Details_Main.html", {
    "object": some_object,   # only if you have something to add into the context. otherwise leave the dictionary empty.
})
于 2013-02-11T15:52:24.790 回答