百日草在安装后不会运行

时间:2012-11-23 09:02:53

标签: django zinnia

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

  
      
  1. django-admin.py startproject yuetu
  2.   
  3. 修改yuetu / yuetu目录中的setting.py,如:
  4.   
      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 /',   包括( 'django.contrib.comments.urls')),

     

4.run python manage.py验证没有错误。   5.run 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  

有人告诉我我错了吗?

1 个答案:

答案 0 :(得分: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')),
)