6

我是 Django 新手,上周刚完成 Django 教程。我今天在我的virtualenv中安装zinnia,我确定我已经安装了所有依赖项,例如PIL,tag,mptt等。 pip install django(版本是1.4.2) pip install zinnia 然后,这是我的详细信息脚步:

  1. django-admin.py 启动项目 yuetu
  2. 修改 yuetu/yuetu 目录下的 setting.py 如下:
      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',
  'zinnia.context_processors.version',
) # Optional

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',
    'django.contrib.comments',
    'tagging',
    'mptt',
    'zinnia',
)

3.修改urls.py如:
url(r'^weblog/', include('zinnia.urls')), url(r'^comments/', include('django.contrib.comments.urls')) ,

4.运行 python manage.py validate 没有错误。5.运行 python manage.py syncdb 没有错误。所有的表都在我的 Mysql 数据库中;6.run python manage.py runserver 没有错误

但是当我使用 127.0.0.1:8000/weblog 浏览页面时,我遇到了一个异常,例如:

NoReverseMatch at /weblog/

u'admin' is not a registered namespace

Request Method:     GET
Request URL:    http://127.0.0.1:8000/weblog/
Django Version:     1.4.2
Exception Type:     NoReverseMatch
Exception Value:    

u'admin' is not a registered namespace

Exception Location:     /root/Envs/yuetu_zinnia/lib/python2.7/site-packages/django/template/defaulttags.py in render, line 424
Python Executable:  /root/Envs/yuetu_zinnia/bin/python
Python Version:     2.7.3
Python Path:    

['/root/Envs/yuetu_zinnia/yuetu',
 '/root/Envs/yuetu_zinnia/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
 '/root/Envs/yuetu_zinnia/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
 '/root/Envs/yuetu_zinnia/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg',
 '/root/Envs/yuetu_zinnia/lib/python2.7/site-packages/MySQL_python-1.2.4c1-py2.7-linux-x86_64.egg',
 '/usr/local/pythonbrew/lib',
 '/root/Envs/yuetu_zinnia/lib/python27.zip',
 '/root/Envs/yuetu_zinnia/lib/python2.7',
 '/root/Envs/yuetu_zinnia/lib/python2.7/plat-linux2',
 '/root/Envs/yuetu_zinnia/lib/python2.7/lib-tk',
 '/root/Envs/yuetu_zinnia/lib/python2.7/lib-old',
 '/root/Envs/yuetu_zinnia/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/root/Envs/yuetu_zinnia/lib/python2.7/site-packages',
 '/root/Envs/yuetu_zinnia/lib/python2.7/site-packages/PIL']




Error during template rendering

In template /root/Envs/yuetu_zinnia/lib/python2.7/site-packages/zinnia/templates/zinnia/entry_list.html, error at line 50
u'admin' is not a registered namespace
40  {% endif %}
41  {% endblock %}
42  
43  {% block content-loop %}
44  {% for object in object_list %}
45  {% with object_content=object.html_content|truncatewords_html:100|safe continue_reading=1 %}
46  {% include "zinnia/_entry_detail.html" %}
47  {% endwith %}
48  {% empty %}
49  <p class="notice">
50  <a href="{% url 'admin:zinnia_entry_add' %}">{% trans "No entries yet." %}</a>
51  </p>
52  {% endfor %}
53  {% endblock %}
54  
55  {% block content-pagination %}
56  {% if is_paginated %}
57  {% zinnia_pagination page_obj %}
58  {% endif %}
59  {% endblock %}
60  

有人告诉我我怎么了?

4

1 回答 1

7

确保您的项目 urls.py 启用了管理系统:

# urls.py
from django.conf.urls import patterns, include, url

# MAKE SURE THESE TWO LINES ARE UNCOMMENTED!
from django.contrib import admin
admin.autodiscover()

urlpatters = patterns('',
    # MAKE SURE THIS NEXT LINE IS UNCOMMENTED!
    url(r'^admin/', include(admin.site.urls)),
    url(r'^weblog/', include('zinnia.urls')),
    url(r'^comments/', include('django.contrib.comments.urls')),
)
于 2012-12-27T20:01:50.183 回答