如何找到导致Django错误的文件?正在获取“Invalid filter:'add'u class'”但没有fi

2024-06-26 09:35:24 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,网站本身运行没有任何错误,我可以找到。在

我已经安装了收缩装置,我正在尝试运行收集静电。在运行过程中,它给了我一个TemplateSyntaxError。回溯中的每个文件都是一个站点包文件,我不知道如何找到错误的来源。有没有什么工具可以检查它,让我看看它是如何处理的,这样我就可以找到错误的来源了吗?在

这是我的回溯:

> You have requested to collect static files at the destination location
> as specified in your settings.
> 
> This will overwrite existing files! Are you sure you want to do this?
> 
> Type 'yes' to continue, or 'no' to cancel: yes
> 
> 0 static files copied, 1249 unmodified. Traceback (most recent call
> last):   File "tools/manage.py", line 16, in <module>
>     execute_manager(settings)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 459, in execute_manager
>     utility.execute()   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 382, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 196, in run_from_argv
>     self.execute(*args, **options.__dict__)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 232, in execute
>     output = self.handle(*args, **options)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 371, in handle
>     return self.handle_noargs(**options)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/shrink/management/commands/collectstatic.py",
> line 58, in handle_noargs
>     templates.add(get_template(pjoin(dirpath, f)))   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader.py",
> line 145, in get_template
>     template, origin = find_template(template_name)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader.py",
> line 134, in find_template
>     source, display_name = loader(name, dirs)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader.py",
> line 42, in __call__
>     return self.load_template(template_name, template_dirs)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader.py",
> line 48, in load_template
>     template = get_template_from_string(source, origin, template_name)   File
> "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader.py",
> line 156, in get_template_from_string
>     return Template(source, origin, name)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 125, in __init__
>     self.nodelist = compile_string(template_string, origin)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 153, in compile_string
>     return parser.parse()   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 267, in parse
>     compiled_result = compile_func(self, token)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py",
> line 214, in do_extends
>     nodelist = parser.parse()   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 267, in parse
>     compiled_result = compile_func(self, token)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py",
> line 189, in do_block
>     nodelist = parser.parse(('endblock',))   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 246, in parse
>     filter_expression = self.compile_filter(token.contents)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 346, in compile_filter
>     return FilterExpression(token, self)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 557, in __init__
>     filter_func = parser.find_filter(filter_name)   File "/home/adam/pyprojects/trekadoo-web/venv/local/lib/python2.7/site-packages/django/template/base.py",
> line 352, in find_filter
>     raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name) django.template.base.TemplateSyntaxError: Invalid filter: 'add_class'

add_类在整个项目中使用了数百次。在


Tags: inpywebhomevenvlibpackageslocal
1条回答
网友
1楼 · 发布于 2024-06-26 09:35:24

好吧,我在PyCharm跑了“管理.pycollectstatic”作为一个python脚本,并在回溯中提到的django核心文件中放置断点。在

然后,我可以返回到帧中,直到找到它引用的文件为止。我不明白为什么那个文件不会在回溯中列出。但是那个文件缺少一个

{% load widget_tweaks %}

添加并修复。在

相关问题 更多 >