Django 1.6使用python 3.3默认的settings.py文件

时间:2013-11-06 23:01:42

标签: django

我在虚拟环境中安装了django 1.6和python3.3 ... 当我使用startproject命令创建项目时,我得到以下内容:

"""
Django settings for ozo project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# 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.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '***********************************'

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

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 = 'ozo.urls'

WSGI_APPLICATION = 'ozo.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_URL = '/static/'

我认为此文件中缺少某些设置。我已经使用django 1.5 startproject命令进行了测试,它设置了如下设置:

MEDIA_URL,STATIC_ROOT,LOGGING,TEMPLATE_DIRS ......等。

2 个答案:

答案 0 :(得分:1)

Django 1.6中简化了默认项目模板。您可以在commit message on GitHub上看到对更改的解释。如果您需要MEDIA_URL之类的设置,请将其添加到其中。

答案 1 :(得分:0)

正如我们从django 1.6发布中看到的那样

https://github.com/django/django/blob/master/docs/releases/1.6.txt

  

简化的默认项目和应用模板

     

使用的默认模板:djadmin:startproject和:djadmin:startapp   已经简化和现代化。 :doc:admin </ref/contrib/admin/index>现在默认在新项目中启用;该   :doc:sites </ref/contrib/sites>框架不再是。 :ref:clickjacking prevention <clickjacking-prevention>现已启用,数据库默认为   SQLite的。

     

如果默认模板不符合您的口味,您可以使用:ref:custom project and app templates <custom-app-and-project-templates>

因此我们可以创建一个应用程序,例如django-admin.py startapp testapp,并创建模板/ testapp目录。然后将html放入test / app / templates / testapp / test.html

我们可以像在这里一样使用views.py中的html

def index(request):
    return render_to_response('testapp/test.html')

我们不应该在settings.py中添加任何内容。