尝试从官方cookbook运行自定义UI应用(“parcel”)进行视图流时,我收到此错误:
/ parcel / delivery / 5 / start / 21 / detail /'viewflow'中的NoReverseMatch 不是注册名称空间
我拍了一张截图:
这是追溯:
div
我试图在viewflow中查找Environment:
Request Method: GET
Request URL: http://localhost:8000/parcel/delivery/5/start/21/detail/
Django Version: 1.10.7
Python Version: 3.4.0
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'material',
'material.frontend',
'viewflow',
'viewflow.frontend',
'apps.parcel']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template error:
In template /Users/paul/delete-viewflows/templates/parcel/delivery/task_detail.html, error at line 0
'viewflow' is not a registered namespace 1 : {% extends 'viewflow/flow/base_task.html' %}
2 : {% load viewflow %}
3 :
4 : {% block nav_parcels_cls %}class="active"{% endblock %}
5 :
6 : {% block task_actions %}
7 : {% flowurl activation.task 'execute' user=request.user as execute_url %}
8 : {% if execute_url %}
9 : <a href="{{ execute_url }}" class="btn primary">Execute</a>
10 : {% endif %}
Traceback:
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/urls/base.py" in reverse
77. extra, resolver = resolver.namespace_dict[ns]
During handling of the above exception ('viewflow'), another exception occurred:
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/core/handlers/exception.py" in inner
42. response = get_response(request)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
217. response = self.process_exception_by_middleware(e, request)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
215. response = response.render()
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/response.py" in render
109. self.content = self.rendered_content
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/response.py" in rendered_content
86. content = template.render(context, self._request)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/backends/django.py" in render
66. return self.template.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
208. return self._render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
174. return compiled_parent._render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
174. return compiled_parent._render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
174. return compiled_parent._render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
174. return compiled_parent._render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
174. return compiled_parent._render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
70. result = block.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
70. result = block.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/loader_tags.py" in render
70. result = block.nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/defaulttags.py" in render
209. nodelist.append(node.render_annotated(context))
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/defaulttags.py" in render
315. return nodelist.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
994. bit = node.render_annotated(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render_annotated
961. return self.render(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in render
1044. output = self.filter_expression.resolve(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in resolve
711. obj = self.var.resolve(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in resolve
852. value = self._resolve_lookup(context)
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/template/base.py" in _resolve_lookup
915. current = current()
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/viewflow/frontend/apps.py" in index_url
55. return reverse('viewflow:index')
File "/Users/paul/.pyenv/versions/dj-viewflow/lib/python3.4/site-packages/django/urls/base.py" in reverse
87. raise NoReverseMatch("%s is not a registered namespace" % key)
Exception Type: NoReverseMatch at /parcel/delivery/5/start/21/detail/
Exception Value: 'viewflow' is not a registered namespace
以包含在我的项目网址中但找不到任何内容。
我该如何解决这个问题?
答案 0 :(得分:0)
更新:请参阅下面的评论,了解实际的正确答案。
问题在于我错过了frontend_urls
我的项目urls.py
。示例代码中缺少这个。
这是工作urls.py
:
from django.contrib import admin
from django.conf.urls import include, url
from django.views import generic
from material.frontend import urls as frontend_urls
urlpatterns = [
url(r'^admin/', admin.site.urls),
url('^$', generic.TemplateView.as_view(template_name='parcel/index.html')),
url('^parcel/', include('apps.parcel.urls', namespace='parcel')),
url('^accounts/', include('django.contrib.auth.urls')),
url(r'', include(frontend_urls)),
]