0

我正在建立一个 django 项目(第一次)。

我尝试配置,但尽管它显示了一些值错误。

这是settings.py

设置.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    ('asit', 'lipun4u@gmail.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'C:\\Users\\asit\\workspace\\tutu\\src\\sqlite.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

TIME_ZONE = 'America/Chicago'
    
SITE_ID = 1

USE_I18N = True

USE_L10N = True

MEDIA_ROOT = 'C:\\django\\media'

MEDIA_URL = ''

ADMIN_MEDIA_PREFIX = '/media/'

SECRET_KEY = 'secret_key'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

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

ROOT_URLCONF = ''

TEMPLATE_DIRS = (
    'C:\\django\\template\\'
    # 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.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

网址.py

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^tutu/', include('tutu.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)

错误是

Exception Type:     ValueError
Exception Value:    

Empty module name

Exception Location:     C:\Python27\lib\site-packages\django\utils\importlib.py in import_module, line 35

有人可以帮助我吗?

4

1 回答 1

1

原因是你有空ROOT_URLCONF。它没有定义任何默认值,因此您应该在此处为您的项目提供实际的 url 配置。很可能只是yourprojectname.urls,像这样

ROOT_URLCONF = 'yourprojectname.urls'

有关详细信息,请参阅 django URLDispacther 文档

于 2013-05-21T18:04:01.267 回答