简体   繁体   中英

Django admin css is missing

I Have tried to solve this issue by following few posts but still not able to solve it.Admin sit is missing its css javascripts and images. My setting.py file is

# 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('\\','/')
)

and display is like

Django administration Welcome, awaisali. Change password / Log out Site administration Auth Groups Add Change Users Add Change Book Authors Add Change Books Add Change Publishers Add Change

Any help would be much appreciated

Okay, after wasting 3-4 days i finally figured what was wrongwith my project. I was using it on Windows 8.1 and therfore due to some unknown issues it was unable to support all static files. i tried to run my project on another system with Windows 7 and it was working perfectly fine. so here it is Windows 8.1 users can stop wasting time on following solutions provided on forums..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM