我按照 Django 教程进行操作,我已经完成了第 4 部分。但是当我回去查看我的管理页面时,它神秘地不再起作用了。所以我搞砸了一点,想出了这个。
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),
#(r'^polls/', include('mysite.polls.urls')),
)
现在我可以进入我的管理页面,但是如果我取消注释掉我的视图的 url(我在 mysite 子文件夹中有另一个 urls.py 管理员不起作用。它会返回以下错误。
Request Method: GET
Request URL: http://192.168.0.5:9000/admin/
Exception Type: TemplateSyntaxError
Exception Value:
Caught an exception while rendering: Tried vote in module mysite.polls.views. Error was: 'module' object has no attribute 'vote'
Original Traceback (most recent call last):
File "/usr/local/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/usr/local/lib/python2.5/site-packages/django/template/defaulttags.py", line 373, in render
url = reverse(self.view_name, args=args, kwargs=kwargs)
File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 254, in reverse
*args, **kwargs)))
File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 227, in reverse
possibilities = self.reverse_dict.getlist(lookup_view)
File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 161, in _get_reverse_dict
for name in pattern.reverse_dict:
File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 169, in _get_reverse_dict
self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern))
File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 136, in _get_callback
raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
ViewDoesNotExist: Tried vote in module mysite.polls.views. Error was: 'module' object has no attribute 'vote'
Exception Location: /usr/local/lib/python2.5/site-packages/django/template/debug.py in render_node, line 81
Python Executable: /usr/bin/python
Python Version: 2.5.1
Python Path: ['/local/Programming/django/mysite', '/usr/lib/python2.5/site-packages/docutils-0.5-py2.5.egg', '/usr/lib/python2.5/site-packages/Pygments-1.0-py2.5.egg', '/usr/lib/python2.5/site-packages/pytz-2008i-py2.5.egg', '/usr/lib/python2.5/site-packages/Genshi-0.6dev_r999-py2.5-linux-i686.egg', '/usr/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg', '/usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg', '/usr/local/lib/python2.5/site-packages/numpy-1.3.0-py2.5-linux-i686.egg', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gtk-2.0', '/usr/local/lib/python2.5/site-packages']
Server time: Sun, 24 May 2009 19:59:08 -0500
Allso 我的观点在管理 url 被注释掉的情况下工作得很好。没有错误。
我正在运行 Django 1.0.2 final。
感谢人们想要提供的任何帮助。
标记