模板语法错误:“settings_tags”不是有效的标签库

发布于 2024-10-09 07:22:33 字数 3871 浏览 0 评论 0原文

当我尝试运行此测试用例时,出现此错误: WHICH IS write in test.py of my django application:

def test_accounts_register( self ):
    self.url = 'http://royalflag.com.pk/accounts/register/'
    self.c = Client()
    self.values = {
        'email': '[email protected]',
        'first_name': 'bilal',
        'last_name': 'bash',
        'password1': 'bilal',
        'password2': 'bilal',
    }
    self.response = self.c.post( self.url, self.values )

my django version is 1.2.1 and python 2.6 and satchmo version is 0.9.2-pre hg-unknown

完整错误日志是:

    .E....
======================================================================
ERROR: test_accounts_register (administration.tests.AccountsRegisterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\pytho\satchmo\administration\tests.py", line 53, in test_accounts_reg
ister
    self.response = self.c.get( self.url )
  File "C:\django\django\test\client.py", line 290, in get
    response = self.request(**r)
  File "C:\django\django\test\client.py", line 230, in request
    response = self.handler(environ)
  File "C:\django\django\test\client.py", line 74, in __call__
    response = self.get_response(request)
  File "C:\django\django\core\handlers\base.py", line 141, in get_response
    return self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "C:\django\django\core\handlers\base.py", line 180, in handle_uncaught_ex
ception
    return callback(request, **param_dict)
  File "C:\django\django\views\defaults.py", line 23, in server_error
    t = loader.get_template(template_name) # You need to create a 500.html templ
ate.
  File "C:\django\django\template\loader.py", line 157, in get_template
    template, origin = find_template(template_name)
  File "C:\django\django\template\loader.py", line 134, in find_template
    source, display_name = loader(name, dirs)
  File "C:\django\django\template\loader.py", line 42, in __call__
    return self.load_template(template_name, template_dirs)
  File "C:\django\django\template\loader.py", line 48, in load_template
    template = get_template_from_string(source, origin, template_name)
  File "C:\django\django\template\loader.py", line 168, in get_template_from_str
ing
    return Template(source, origin, name)
  File "C:\django\django\template\__init__.py", line 158, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "C:\django\django\template\__init__.py", line 186, in compile_string
    return parser.parse()
  File "C:\django\django\template\__init__.py", line 282, in parse
    compiled_result = compile_func(self, token)
  File "C:\django\django\template\defaulttags.py", line 921, in load
    (taglib, e))
TemplateSyntaxError: 'settings_tags' is not a valid tag library: Template librar
y settings_tags not found, tried django.templatetags.settings_tags,satchmo_store
.shop.templatetags.settings_tags,django.contrib.admin.templatetags.settings_tags
,django.contrib.comments.templatetags.settings_tags,django.contrib.humanize.temp
latetags.settings_tags,livesettings.templatetags.settings_tags,sorl.thumbnail.te
mplatetags.settings_tags,satchmo_store.contact.templatetags.settings_tags,tax.te
mplatetags.settings_tags,pagination.templatetags.settings_tags,product.templatet
ags.settings_tags,payment.templatetags.settings_tags,payment.modules.giftcertifi
cate.templatetags.settings_tags,satchmo_utils.templatetags.settings_tags,app_plu
gins.templatetags.settings_tags,tinymce.templatetags.settings_tags

----------------------------------------------------------------------
Ran 6 tests in 47.468s

FAILED (errors=1)
Destroying test database 'default'...

i got this error when i try to run this test case: WHICH IS written in tests.py of my django application:

def test_accounts_register( self ):
    self.url = 'http://royalflag.com.pk/accounts/register/'
    self.c = Client()
    self.values = {
        'email': '[email protected]',
        'first_name': 'bilal',
        'last_name': 'bash',
        'password1': 'bilal',
        'password2': 'bilal',
    }
    self.response = self.c.post( self.url, self.values )

my django version is 1.2.1 and python 2.6 and satchmo version is 0.9.2-pre hg-unknown

the complete error log is:

    .E....
======================================================================
ERROR: test_accounts_register (administration.tests.AccountsRegisterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\pytho\satchmo\administration\tests.py", line 53, in test_accounts_reg
ister
    self.response = self.c.get( self.url )
  File "C:\django\django\test\client.py", line 290, in get
    response = self.request(**r)
  File "C:\django\django\test\client.py", line 230, in request
    response = self.handler(environ)
  File "C:\django\django\test\client.py", line 74, in __call__
    response = self.get_response(request)
  File "C:\django\django\core\handlers\base.py", line 141, in get_response
    return self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "C:\django\django\core\handlers\base.py", line 180, in handle_uncaught_ex
ception
    return callback(request, **param_dict)
  File "C:\django\django\views\defaults.py", line 23, in server_error
    t = loader.get_template(template_name) # You need to create a 500.html templ
ate.
  File "C:\django\django\template\loader.py", line 157, in get_template
    template, origin = find_template(template_name)
  File "C:\django\django\template\loader.py", line 134, in find_template
    source, display_name = loader(name, dirs)
  File "C:\django\django\template\loader.py", line 42, in __call__
    return self.load_template(template_name, template_dirs)
  File "C:\django\django\template\loader.py", line 48, in load_template
    template = get_template_from_string(source, origin, template_name)
  File "C:\django\django\template\loader.py", line 168, in get_template_from_str
ing
    return Template(source, origin, name)
  File "C:\django\django\template\__init__.py", line 158, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "C:\django\django\template\__init__.py", line 186, in compile_string
    return parser.parse()
  File "C:\django\django\template\__init__.py", line 282, in parse
    compiled_result = compile_func(self, token)
  File "C:\django\django\template\defaulttags.py", line 921, in load
    (taglib, e))
TemplateSyntaxError: 'settings_tags' is not a valid tag library: Template librar
y settings_tags not found, tried django.templatetags.settings_tags,satchmo_store
.shop.templatetags.settings_tags,django.contrib.admin.templatetags.settings_tags
,django.contrib.comments.templatetags.settings_tags,django.contrib.humanize.temp
latetags.settings_tags,livesettings.templatetags.settings_tags,sorl.thumbnail.te
mplatetags.settings_tags,satchmo_store.contact.templatetags.settings_tags,tax.te
mplatetags.settings_tags,pagination.templatetags.settings_tags,product.templatet
ags.settings_tags,payment.templatetags.settings_tags,payment.modules.giftcertifi
cate.templatetags.settings_tags,satchmo_utils.templatetags.settings_tags,app_plu
gins.templatetags.settings_tags,tinymce.templatetags.settings_tags

----------------------------------------------------------------------
Ran 6 tests in 47.468s

FAILED (errors=1)
Destroying test database 'default'...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

寂寞笑我太脆弱 2024-10-16 07:22:33

在我看来,您的模板中可能有类似 {% load settings_tags %} 的代码。 Django 在已安装应用程序的目录中查找 templatetags/settings_tags.py 文件。这是没有找到这样的文件的结果。也许包含它的应用程序不在您的 INSTALLED_APPS 中,或者可能是一个拼写错误。当您将此网址输入浏览器时,您应该会收到相同的错误。

It seems to me you probably have a code like {% load settings_tags %} somewhere in your template. Django looks for templatetags/settings_tags.py file in your installed apps' directories. This is the result of not finding a file like this. Maybe the app, which contains it is not in your INSTALLED_APPS or maybe it's a typo. You should be getting the same error when you put this url in your browser.

若水微香 2024-10-16 07:22:33

有时,当您忘记将 __ init __.py 放入包中时,就会发生这种情况。

Sometimes this happens when you forgot to put an __ init __.py in the package.

蓝颜夕 2024-10-16 07:22:33

就像@AJJ所说,您可能需要重新启动服务器才能加载新标签

Like @AJJ said, you may have to restart the server to get the new tags loaded

染年凉城似染瑾 2024-10-16 07:22:33

这是此软件包的常见问题。当你从pypi获取它时,它不包含模板标签:settings_tag.py,这将导致错误'settings_tags'不是有效的标签库:找不到模板库settings_tags。

当前的解决方案是从 github zip 安装它。

This is a common issue for this package. When you get it from pypi, it does not contains the template tag: settings_tag.py and that will cause the error 'settings_tags' is not a valid tag library: Template library settings_tags not found.

The current solution is to install it from the github zip.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文