我目前正在尝试通过RapidSMS运行Project Mwana,但遇到来自{%get_tabs as tabs}的No Reverse Match错误。这是追溯:
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.2.3
Python Version: 2.7.3
Installed Applications:
['mwana.apps.broadcast',
'mwana.apps.tlcprinters',
'south',
'django_nose',
'djtables',
'rapidsms',
'rapidsms.contrib.handlers',
'rapidsms.contrib.ajax',
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.sessions',
'django.contrib.contenttypes',
'rapidsms.contrib.export',
'rapidsms.contrib.httptester',
'rapidsms.contrib.messagelog',
'rapidsms.contrib.messaging',
'rapidsms.contrib.scheduler',
'mwana.apps.echo',
'mwana.apps.contactsplus',
'mwana.apps.registration',
'mwana.apps.agents',
'mwana.apps.broadcast',
'mwana.apps.labresults',
'mwana.apps.reminders',
'mwana.apps.location_importer',
'mwana.apps.reports',
'mwana.apps.training',
'mwana.apps.help',
'mwana.apps.alerts',
'mwana.apps.locations',
'mwana.apps.patienttracing',
'mwana.apps.hub_workflow',
'mwana.apps.stringcleaning',
'mwana.apps.translator',
'rapidsms.contrib.default',
'eav',
'uni_form',
'people',
'mwana.apps.nutrition',
'mwana.apps.reports.webreports']
Installed Middleware:
['django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'mwana.middleware.LoginRequired']
Template error:
In template /root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/rapidsms/templates/layout.html, error at line 49
Caught NoReverseMatch while rendering: Reverse for 'rapidsms.contrib.messagelog.views.message_log' with arguments '()' and keyword arguments '{}' not found.
39 : </h1>
40 : </div>
41 :
42 : {% block auth %}
43 : <div id="auth">{% if user.is_authenticated %}
44 : <a href="{% url rapidsms-logout %}">{% trans "Log out" %} {{ user.username }}</a>{% else %}
45 : <a href="{% url rapidsms-login %}">{% trans "Log in" %}</a>{% endif %}
46 : </div>
47 : {% endblock %}
48 :
49 : {% get_tabs as tabs %}
50 :
51 : <ul id="tabs">{% for tab in tabs %}
52 : <li class="app-{{ tab.name }}{% if tab.is_active %} active{% endif %}">
53 : <a href="{{ tab.url }}"><span>{{ tab.caption }}</span></a>
54 : </li>{% endfor %}
55 : </ul>
56 :
57 : {% block page_tabs %}
58 : {% endblock %}
59 : </div>
Traceback:
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
95. response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/jackie/mwana/mwana/middleware.py" in process_view
34. return login_required(view_func)(request, * view_args, ** view_kwargs)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
25. return view_func(request, *args, **kwargs)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/views/decorators/http.py" in inner
37. return func(request, *args, **kwargs)
File "/home/jackie/mwana/mwana/apps/reports/views.py" in malawi_reports
129. }, context_instance=RequestContext(request))
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
186. return t.render(context_instance)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/__init__.py" in render
173. return self._render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/__init__.py" in _render
167. return self.nodelist.render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/__init__.py" in render
796. bits.append(self.render_node(node, context))
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
72. result = node.render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
125. return compiled_parent._render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/__init__.py" in _render
167. return self.nodelist.render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/__init__.py" in render
796. bits.append(self.render_node(node, context))
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
72. result = node.render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/__init__.py" in render
796. bits.append(self.render_node(node, context))
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
72. result = node.render(context)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/rapidsms/templatetags/tabs_tags.py" in render
58. tab.is_active = tab.url == request.get_full_path()
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/rapidsms/templatetags/tabs_tags.py" in url
35. return reverse(self._view)
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
351. *args, **kwargs)))
File "/root/.virtualenvs/mwana-dev/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
297. "arguments '%s' not found." % (lookup_view_s, args, kwargs))
Exception Type: TemplateSyntaxError at /
Exception Value: Caught NoReverseMatch while rendering: Reverse for 'rapidsms.contrib.messagelog.views.message_log' with arguments '()' and keyword arguments '{}' not found.
我很确定我在tabs_tags.py中找到了违规的反向字段,我只是想不通如何修复它。
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4
import types
import threading
from functools import wraps
from django import template
from django.conf import settings
from django.core.urlresolvers import get_resolver, reverse, RegexURLPattern
from django.utils.importlib import import_module
from django.template import Variable
register = template.Library()
class Tab(object):
def __init__(self, view, caption=None):
self._view = view
self._caption = caption
def _auto_caption(self):
func_name = self._view.split('.')[-1] # my_view
return func_name.replace("_", " ").title() # My View
@property
def url(self):
"""
Return the URL of this tab.
Warning: If this tab's view function cannot be reversed, Django
will silently ignore the exception, and return the value of the
TEMPLATE_STRING_IF_INVALID setting.
"""
return reverse(self._view)
@property
def caption(self):
return self._caption or self._auto_caption()
另外,作为一个说明,我是一个新手,生活在马拉维(非洲)的一个小乡村小镇,其唯一的编码经验来自于在MS Excel中使用Visual Basic。我一直在想出这些东西,所以请解释一下你和孩子说话的任何解决方案。如果还有其他需要的信息,请告诉我。