TemplateSyntaxError:'settings_tags'不是有效的标记库

Bil*_*rat 7 python django satchmo

当我尝试运行此测试用例时出现此错误:这是在我的django应用程序的tests.py中写的:

def test_accounts_register( self ):
    self.url = 'http://royalflag.com.pk/accounts/register/'
    self.c = Client()
    self.values = {
        'email': 'bilal@gmail.com',
        'first_name': 'bilal',
        'last_name': 'bash',
        'password1': 'bilal',
        'password2': 'bilal',
    }
    self.response = self.c.post( self.url, self.values )
Run Code Online (Sandbox Code Playgroud)

我的django版本是1.2.1和python 2.6,satchmo版本是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'...
Run Code Online (Sandbox Code Playgroud)

VoY*_*VoY 19

在我看来,你可能{% load settings_tags %}在模板中的某个地方有一个代码.Django templatetags/settings_tags.py在已安装的应用程序目录中查找文件.这是找不到这样的文件的结果.也许包含它的应用程序不在你的INSTALLED_APPS或者它可能是一个错字.将此URL放入浏览器时,您应该收到同样的错误.

  • 我不确定这是否是正常行为,但我不得不重新启动服务器以加载过滤器文件. (61认同)
  • 服务器重启帮助!这肯定是一个错误 - 你先生@AJweb应该很棒! (4认同)
  • @AJweb我也是.我重新启动了服务器,它开始工作了. (3认同)
  • 我认为重新启动服务器是必要的.重新启动服务器也适用于我的情况. (2认同)

ala*_*mre 15

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

  • 是啊!就在这里 (4认同)

Pie*_*NAY 7

就像@AJJ所说,你可能不得不重新启动服务器来加载新标签