0

我有一个新安装的 django-cms。我可以访问带有 django-cms 徽标的起始页(django 1.4,django-cms 2.3rc2.post0)。第一页有两个超链接,“admin”http://v11.python.centos/zh-cn/admin/和“adding” http://v11.python.centos/zh-cn/admin/cms/page/add/。当我访问它们时出现错误 404。当我http://v11.python.centos/admin/直接输入地址栏时,我也得到了错误 404。当我检查 apache 日志时,我得到了很多错误,第一个是File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__. 有没有人有类似的经历?任何话都将不胜感激。有关错误的更多详细信息,apache的错误日志和我urls.py的如下,感谢您的时间。

关于 v11.python.centos-error_log 的详细信息:

[Sun Jul 15 16:56:24 2012] [info] mod_wsgi (pid=7762): Shutdown requested 'v11.python.centos'.
[Sun Jul 15 16:56:24 2012] [info] mod_wsgi (pid=7762): Stopping process 'v11.python.centos'.
[Sun Jul 15 16:56:24 2012] [info] mod_wsgi (pid=7762): Destroying interpreters.
[Sun Jul 15 16:56:24 2012] [info] mod_wsgi (pid=7762): Cleanup interpreter ''.
[Sun Jul 15 16:56:24 2012] [info] mod_wsgi (pid=7762): Terminating Python.
[Sun Jul 15 16:56:24 2012] [info] mod_wsgi (pid=7762): Python has shutdown.
[Sun Jul 15 16:56:27 2012] [info] mod_wsgi (pid=7831): Attach interpreter ''.
[Sun Jul 15 16:56:31 2012] [info] mod_wsgi (pid=7831): Create interpreter 'v11.python.centos|'.
[Sun Jul 15 16:56:31 2012] [info] [client 10.7.6.186] mod_wsgi (pid=7831, process='v11.python.centos', application='v11.python.centos|'): Loading WSGI script '/var/www/vhost11/tdjcms/tdjcms/wsgi.py'.
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186] mod_wsgi (pid=7831): Exception occurred processing WSGI script '/var/www/vhost11/tdjcms/tdjcms/wsgi.py'.
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186] Traceback (most recent call last):
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     self.load_middleware()
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 45, in load_middleware
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     mod = import_module(mw_module)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     __import__(name)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django_cms-2.3rc2.post0-py2.6.egg/cms/__init__.py", line 9, in <module>
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     patch_settings()
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django_cms-2.3rc2.post0-py2.6.egg/cms/conf/__init__.py", line 36, in patch_settings
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     post_patch_check()
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django_cms-2.3rc2.post0-py2.6.egg/cms/conf/patch.py", line 56, in post_patch_check
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     if not validate_template(template[0], ['js', 'css']):
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/sekizai/helpers.py", line 97, in validate_template
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     found = get_namespaces(template)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/sekizai/helpers.py", line 88, in get_namespaces
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     return _scan_namespaces(compiled_template.nodelist)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/sekizai/helpers.py", line 78, in _scan_namespaces
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     found += _extend_nodelist(node)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/sekizai/helpers.py", line 51, in _extend_nodelist
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     _extend_blocks(extend_node, blocks)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/sekizai/helpers.py", line 24, in _extend_blocks
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     parent = extend_node.get_parent(None)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/loader_tags.py", line 98, in get_parent
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     return get_template(parent)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/loader.py", line 145, in get_template
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     template, origin = find_template(template_name)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/loader.py", line 134, in find_template
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     source, display_name = loader(name, dirs)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/loader.py", line 42, in __call__
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     return self.load_template(template_name, template_dirs)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/loader.py", line 48, in load_template
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     template = get_template_from_string(source, origin, template_name)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/loader.py", line 156, in get_template_from_string
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     return Template(source, origin, name)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/base.py", line 125, in __init__
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     self.nodelist = compile_string(template_string, origin)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/base.py", line 153, in compile_string
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     return parser.parse()
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/base.py", line 265, in parse
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     self.invalid_block_tag(token, command, parse_until)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]   File "/usr/lib/python2.6/site-packages/django/template/base.py", line 321, in invalid_block_tag
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186]     raise self.error(token, "Invalid block tag: '%s'" % command)
[Sun Jul 15 16:56:31 2012] [error] [client 10.7.6.186] TemplateSyntaxError: Invalid block tag: 'render_block'
[Sun Jul 15 03:56:34 2012] [error] /usr/lib/python2.6/site-packages/django_mptt-0.5.2-py2.6.egg/mptt/models.py:305: DeprecationWarning: Implicit manager CMSPlugin.tree will be removed in django-mptt 0.6.  Explicitly define a TreeManager() on your model to remove this warning.
[Sun Jul 15 03:56:34 2012] [error]   DeprecationWarning
[Sun Jul 15 03:56:34 2012] [error] /usr/lib/python2.6/site-packages/django/template/defaulttags.py:1235: DeprecationWarning: The syntax for the url template tag is changing. Load the `url` tag from the `future` tag library to start using the new behavior.
[Sun Jul 15 03:56:34 2012] [error]   category=DeprecationWarning)

我的网址.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings

admin.autodiscover()

urlpatterns = patterns('',
    url(r'^', include('cms.urls')),
    url(r'^admin/', admin.site.urls),
)

if settings.DEBUG:
    urlpatterns = patterns('',
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    url(r'', include('django.contrib.staticfiles.urls')),
) + urlpatterns

附录:settings.py

# Django settings for tdjcms project.
import os
gettext = lambda s: s
SETTINGS_PATH = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'djcms',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': 'python',                  # Not used with sqlite3.
        'HOST': 'python.centos',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'zh-cn'
LANGUAGES = [
    ('zh-cn', 'Chinese'),
]

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(SETTINGS_PATH,"../media")

# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(SETTINGS_PATH, "../static")

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

#ADMIN_MEDIA_PREFIX = '/static/admin/"

# Additional locations of static files
STATICFILES_DIRS = (
    # 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.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 's*)(xzab)=ijji8ho%6q)s=r^f8&amp;pb6z)sp3uc90a_&amp;=0iy5kw'

# List of callables that know how to import templates from various sources.
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',
    'cms.middleware.multilingual.MultilingualURLMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.i18n',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'cms.context_processors.media',
    'sekizai.context_processors.sekizai',
)

ROOT_URLCONF = 'tdjcms.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'tdjcms.wsgi.application'

TEMPLATE_DIRS = (
    # 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.
    os.path.join(SETTINGS_PATH, "../templates"),
)

CMS_TEMPLATES = (
    ('template_1.html', 'Template One'),
    ('template_2.html', 'Template Two'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'cms',
    'menus',
    'mptt',
    'south',
    'sekizai',
    'filer',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_image',
    'cmsplugin_filer_teaser',
    'cmsplugin_filer_video',
    'cms.plugins.flash',
    'cms.plugins.googlemap',
    'cms.plugins.link',
    'cms.plugins.picture',
    'cms.plugins.snippet',
    'cms.plugins.text',
    'cms.plugins.twitter',
    'reversion',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
        'class': 'django.utils.log.AdminEmailHandler'    
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

Apache配置文件:http-vhost11.conf

<VirtualHost *:80>
    ServerAdmin python@v11.python.centos
    DocumentRoot "/var/www/vhost11"
    ServerName v11.python.centos
    ServerAlias www.v11.python.centos.com

    ErrorLog "logs/v11.python.centos-error_log"
    CustomLog "logs/v11.python.centos-access_log" common

    <Directory /var/www/vhost11>
        Order allow,deny
        Allow from all
    </Directory>  

    WSGIDaemonProcess v11.python.centos processes=1 threads=1 display-name=%{GROUP}
    WSGIProcessGroup v11.python.centos

    WSGIScriptAlias /app /var/www/vhost11/wsgi-scripts/myapp.wsgi

   <Directory /var/www/vhost11/wsgi-scripts>
        Order allow,deny
        Allow from all
    </Directory>   

Include conf/extra/tdjcms-vhosts.conf
</VirtualHost>

tdjcms-vhosts.conf

WSGIScriptAlias / /var/www/vhost11/tdjcms/tdjcms/wsgi.py
<Directory /var/www/vhost11/tdjcms>
    Allow from all
</Directory>
<Directory /var/www/vhost11/tdjcms/tdjcms>
    Order allow,deny
    Allow from all
</Directory>

Alias /static/ /var/www/vhost11/tdjcms/static/    
Alias /media/ /var/www/vhost11/tdjcms/media/

项目树:

tdjcms
|-- manage.py
|-- media
|-- static
|   `-- cms -> /usr/lib/python2.6/site-packages/django_cms-2.3rc2.post0-py2.6.egg/cms/static/cms
|-- tdjcms
|   |-- __init__.py
|   |-- __init__.pyc
|   |-- settings.py
|   |-- settings.pyc
|   |-- urls.py
|   |-- urls.pyc
|   |-- wsgi.py
|   `-- wsgi.pyc
`-- templates
    |-- base.html
    |-- template_1.html
    `-- template_2.html
4

0 回答 0