注册 登录
编程论坛 Python论坛

setting 设置了总是报错

cai410579517 发布于 2014-05-21 15:36, 2037 次点击
错误显示:
只有本站会员才能查看附件,请 登录


setting代码配置
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^_5!#_w(@h#3*f2q(p8c6p)sd0et6@_hx!8*%tdzjbaqfx&h^8'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
ROOT_DIR = ''
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
# Application definition
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#   'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# List of callables that know how to import templates from various sources.
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bgstage',
)
MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.',
  # 'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',

)
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#    'django.template.loaders.eggs.Loader',
)
STATIC_ROOT = ''
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
TEMPLATES_DIR = (
    os.path.join(ROOT_DIR, '../templates').replace('\\','/'),
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)
ROOT_URLCONF = 'setting.urls'
WSGI_APPLICATION = 'setting.wsgi.application'
# Database
# https://docs.
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
# Internationalization
# https://docs.
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.
STATIC_URL = '/static/'

view.py从这里开始
from django.shortcuts import render_to_response
from setting import settings
from django.http import HttpResponse  
from django.http import HttpResponseRedirect
from django.contrib.auth.views import logout
from django.contrib.auth.decorators import login_required
# from common import remote_data
# from common.ajax import standardAjax
# from common.view_common import *
from django.contrib.auth.views import logout
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
import random
import time
 
def statrtpro(request):
    return HttpResponse("Hello NowaMagic!")

def index(request):
  ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
  paths=os.path.join(ROOT_DIR).replace('\\','/')
  print paths,'aaas'
  print sys.path.append(paths)
  return render_to_response(
  'index.html',
  {},
  context_instance=RequestContext(request))
1 回复
#2
cai4105795172014-05-30 14:32
版主我需要帮助 给点说明吧  为什么会这样
1