使用bootstrap-admin的Django 1.9.7不起作用

时间:2016-07-16 09:01:38

标签: python django django-admin

我今天刚认识bootstrap-admin,我想用我的django项目尝试它,但无论我如何更改我的设置,页面都没有以合适的方式显示,我做错了什么?

(Django 1.9.7 / Python 3.5.2 / bootstrap-admin-0.3.6)

settings.py

import os

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


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'w!7!ah1(h_$e-s5=6=!53pti#z^drkwayc6k6e+-etfx&2lrje'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'bootstrap_admin',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls',
]

from django.conf import global_settings


MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

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.core.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.request',
            ],
        },
    },
]

WSGI_APPLICATION = 'mysite.wsgi.application'
BOOTSTRAP_ADMIN_SIDEBAR_MENU = True

# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':  'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':    'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'

1 个答案:

答案 0 :(得分:0)

Django Admin在Django 1.9中完全重新设计。 [django-admin-boostrap]的最后更新是一年多以前(早于Django 1.9发布日期)。

an issue is opened关于此事。

无论如何,该项目看起来已经死了。在挑选模块/应用时,要注意项目状态,历史和更新频率。特别是如果你没有经验,建议避免使用太多"未经证实的"模块。否则,当发生错误时,可能很难发现问题是来自您的代码,来自第三方模块还是来自冲突/不兼容的第三方模块。

如果您只使用最新且广泛采用的模块,您可以非常肯定,如果发生错误,您应该受到责备(这是一件好事)。