我正在使用django,并集成了第三方应用程序-django_helpdesk。我以前曾进行过此操作,并且自从我更新到django 1.11和Helpdesk 0.2.10时遇到了错误。
当我运行管理命令get_email时-我收到一个错误“ django.urls.exceptions.NoReverseMatch:'en-us'不是注册的名称空间”
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 77, in handle
process_email(quiet=quiet)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 110, in process_email
process_queue(q, logger=logger)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 240, in process_queue
ticket = ticket_from_message(message=full_message, queue=q, logger=logger)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 503, in ticket_from_message
context = safe_template_context(t)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/lib.py", line 260, in safe_template_context
'ticket': ticket_template_context(ticket),
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/lib.py", line 220, in ticket_template_context
attr = getattr(ticket, field, None)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/models.py", line 547, in _get_ticket_url
reverse('helpdesk:public_view'),
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/urls/base.py", line 87, in reverse
raise NoReverseMatch("%s is not a registered namespace" % key)
django.urls.exceptions.NoReverseMatch: 'en-us' is not a registered namespace *en-us is whatever I put in my language code within settings.py*
我碰到了this article,并尝试将引用回溯到底部的reverse()调用切换为reverse_lazy()... line 546 of helpdesk/models.py,但是我仍然收到相同的错误,只有几个错误排列代码。
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 77, in handle
process_email(quiet=quiet)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 110, in process_email
process_queue(q, logger=logger)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 240, in process_queue
ticket = ticket_from_message(message=full_message, queue=q, logger=logger)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/management/commands/get_email.py", line 503, in ticket_from_message
context = safe_template_context(t)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/lib.py", line 260, in safe_template_context
'ticket': ticket_template_context(ticket),
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/lib.py", line 220, in ticket_template_context
attr = getattr(ticket, field, None)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/helpdesk/models.py", line 549, in _get_ticket_url
self.submitter_email
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/utils/functional.py", line 119, in __text_cast
return func(*self.__args, **self.__kw)
File "/home/website/public_html/prodenv/lib/python2.7/site-packages/django/urls/base.py", line 87, in reverse
raise NoReverseMatch("%s is not a registered namespace" % key)
django.urls.exceptions.NoReverseMatch: 'en-us' is not a registered namespace
我的问题似乎与mentioned here相似,但是我没有任何解决办法。
from django.conf import settings
from django.conf.urls import url, include
from django.views.generic import TemplateView
from django.contrib import admin
from products.views import home, contact, thanks
urlpatterns = [
url(r"^$", home),
url(r"^aboutus/$", TemplateView.as_view(template_name="aboutus.html"), name="aboutus"),
url(r"^privacy/$", TemplateView.as_view(template_name="privacy.html"), name="privacy"),
url(r"^terms/$", TemplateView.as_view(template_name="terms.html"), name="terms"),
url(r'^grappelli/', include('grappelli.urls')),
url(r"^admin/", admin.site.urls),
url(r"^account/", include("maxaccount.urls")), #hazmax specific account settings
url(r"^ticket/", include("questions.urls")),
url(r"^ticket/", include("helpdesk.urls")),
...
]
from django.conf.urls import url, include
from questions.views import myQuestions, create_ticket, view_ticket
app_name="questions"
urlpatterns = [
url(r'^MyQuestions/$',myQuestions, name='my_questions'),
url(r'^tickets/submit/$',create_ticket, name='create_ticket'),
]