Django admin css丢失了

时间:2014-08-07 08:14:30

标签: python css django

我试过通过以下几个帖子来解决这个问题,但仍然无法解决它.Admin sit缺少它的css javascripts和图像。我的setting.py文件是

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import os.path

BASE_DIR = os.path.dirname(os.path.dirname(__file__))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-g&@qu=+mm-li1xtsz_9a7c5uz6-&jq3y==7ib1%8zy2f@-_q4'

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

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'book',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'Onlinebook.urls'

WSGI_APPLICATION = 'Onlinebook.wsgi.application'


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

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

# Internationalization
# https://docs.djangoproject.com/en/1.6/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.6/howto/static-files/
STATIC_ROOT = os.path.join(os.path.dirname(__file__), 'static/')

STATIC_URL = '/static/'


# STATICFILES_DIRS = (
#     'K:/Analytics/Java/Onlinebook/src/book',
#      
#     # Put strings here, like "/home/html/static" or "C:/www/django/static".
#     # Always use forward slashes, even on Windows.
#     # Don't forget to use absolute paths, not relative paths.
# )

TEMPLATE_DIRS= (
              os.path.join (os.path.dirname(__file__),'templates').replace('\\','/')
)

和显示就像

Django管理 欢迎,awaisali。更改密码/注销 网站管理 验证 群组添加更改 用户添加更改 书 作者添加更改 书籍添加更改 发布商添加更改

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

好的,浪费了3-4天后我终于想到了我的项目出了什么问题。我在Windows 8.1上使用它,因为一些未知的问题它无法支持所有静态文件。 我试图在Windows 7的另一个系统上运行我的项目,它工作得非常好。所以这里是Windows 8.1用户可以停止在论坛上提供的以下解决方案上浪费时间..