我能';t在我的django项目中导入标记
使用django的my的当前版本是1.6.3 我写代码我能';t在我的django项目中导入标记,django,markup,Django,Markup,使用django的my的当前版本是1.6.3 我写代码 {% load markup %} 在我的blog_list.html中 我得到了错误的答案 'markup' is not a valid tag library: Template library markup not found, tried django.templatetags.markup,django.contrib.admin.templatetags.markup,django.contrib.staticfiles.t
{% load markup %}
在我的blog_list.html中
我得到了错误的答案
'markup' is not a valid tag library: Template library markup not found, tried django.templatetags.markup,django.contrib.admin.templatetags.markup,django.contrib.staticfiles.templatetags.markup`
所以我检查了文档,找到了方法,然后添加'django.contrib.markup'来安装应用程序设置。当我运行服务器时,我得到了以下信息:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
ImportError: No module named markup
回溯(最近一次呼叫最后一次):
文件“manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/core/management/_init__.py”,第399行,从命令行执行
utility.execute()
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/core/management/_init__.py”,第392行,在execute中
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py”,第242行,从_argv运行
self.execute(*args,**选项._dict__;
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/core/management/base.py”,执行中第280行
翻译。激活('en-us')
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/utils/translation/_init__.py”,第130行,在activate中
返回_trans.activate(语言)
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第188行,在activate中
_active.value=翻译(语言)
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第177行,翻译版
默认\u translation=\u fetch(settings.LANGUAGE\u代码)
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第159行,在
app=导入模块(appname)
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/django/utils/importlib.py”,第40行,在导入模块中
__导入(名称)
ImportError:没有名为markup的模块
所以我用macports搜索了标记,并安装了py27 markupsafe。我也不能导入它。我该怎么办?如果你看一下,你会注意到以下几点:
django.contrib.markup will be removed following an accelerated deprecation.
这意味着从1.6开始,标记不会自动包含在Django中。你可以阅读更多关于它的内容
作为替代,我已成功安装了一个模板标签:
{% load markdown_deux_tags %}
{{ myvar|markdown }}
如果你看一下,你会注意到以下几点:
django.contrib.markup will be removed following an accelerated deprecation.
这意味着从1.6开始,标记不会自动包含在Django中。你可以阅读更多关于它的内容
作为替代,我已成功安装了一个模板标签:
{% load markdown_deux_tags %}
{{ myvar|markdown }}
假设您使用的是旧的Django(在这之前已被删除),请将以下内容添加到settings.py中已安装的_应用程序中: “django.contrib.markup”
这应该可以解决问题。假设您使用的是旧的Django(在它被删除之前),请将以下内容添加到您的settings.py中已安装的应用程序中: “django.contrib.markup”
检查文档后,标记似乎不是有效的模板标记。您必须使用
{%load my_custom_tag_name%}
加载自定义标记。检查文档后,标记似乎不是有效的模板标记。您必须使用{%load my_custom_tag_name%}
加载自定义标记。