add_to_builtins('gravatar.gravatar')
跟踪(最近一次调用):
在run self.result = application(self.environ,self.start_response)中,第283行文件
文件"C:\development\python\Lib\site-packages\django\contrib\staticfiles\handlers.py",第68行,在调用返回self.application(environ,start_response)中
文件"C:\development\python\Lib\site-packages\django\core\handlers\wsgi.py",第272行,在调用 response =self.get_response(请求)中
文件"C:\development\python\Lib\site-packages\django\core\handlers\base.py",第169行,在get_response response =self.handle_uncaught_exception(请求、解析器、sys.exc_info())中
文件"C:\development\python\Lib\site-packages\django\core\handlers\base.py",第203行,在handle_uncaught_exception返回debug.technical_500_response(请求,*exc_info)中
文件"C:\development\python\Lib\site-packages\django\views\debug.py",第59行,在technical_500_response html = reporter.get_traceback_html()中
文件"C:\development\python\Lib\site-packages\django\views\debug.py",第128行,在get_traceback_html t=get_traceback_html(TECHNICAL_500_TEMPLATE,name=‘Technical500Template’)中
文件"C:\development\python\Lib\site-packages\django\template\base.py",第108行,在init self.nodelist = compile_string(template_string,原产地)中
文件"C:\development\python\Lib\site-packages\django\template\base.py",第135行,在compile_string解析器= parser_class(lexer.tokenize())中
文件"C:\development\python\Lib\site-packages\django\template\debug.py",第34行,在init超级(DebugParser,self).init(lexer) )中
文件"C:\development\python\Lib\site-packages\django\template\base.py",第208行,在init print lib.tags中
AttributeError:'NoneType‘对象没有属性’标记‘
如果我没有任何问题,使用凹版头像,如果我不使用add_to_builtins的功能-也就是说,在我的视图中普通的旧加载标签。我只是公平地使用了它,所以我想我可能会使用add_to_builtins功能。
从外观上看,导入的版本崩溃是因为import_library(module) for gravatar.gravatar不返回任何内容(我之所以知道这一点,是因为我打印出了该行,而它却没有返回)--我所做的工作有什么问题?
发布于 2012-06-22 03:41:05
哦,神通。
好的,所以我在如何使用add_to_builtins导入这个文件时都错了--我需要做的是:
add_to_builtins('gravatar.templatetags.gravatar')我不知道为什么,但这是个不错的选择。现在我不需要任何乱七八糟的“加载”语句,我可以很高兴地调用
{% gravatar story.user 40 %}从我的任何模板。耶!
https://stackoverflow.com/questions/11149696
复制相似问题