Django Nonrel 中的 {% markdown %} 和 {% Textile %} 过滤器出错
我在 Django Nonrel 中使用 Markdown 时遇到问题。我遵循了这个说明(添加了'django.contrib.markup'
到 INSTALLED_APPS
,在模板中包含 {% load markup %}
并在安装 python-markdown 后使用 |markdown
过滤器),但我得到了下列的错误:
Error in {% markdown %} filter: The Python markdown library isn't installed.
在这一行中:
/path/to/project/django/contrib/markup/templatetags/markup.py in markdown
they will be silently ignored.
"""
try:
import markdown
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError("Error in {% markdown %} filter: The Python markdown library isn't installed.") ...
return force_unicode(value)
else:
# markdown.version was first added in 1.6b. The only version of markdown
# to fully support extensions before 1.6b was the shortlived 1.6a.
if hasattr(markdown, 'version'):
extensions = [e for e in arg.split(",") if e]
很明显 import markdown
导致了问题,但是当我运行时:
$ python manage.py shell
>>> import elementtree
>>> import markdown
一切正常。
运行 Markdown 2.0.3、Python 2.7 和最新版本的 Django Nonrel。
更新:我安装了纺织品,但它不起作用。它会产生相同的错误。
更新 2:这是与 Django Nonrel 相关的问题。我采用了一个较旧的 Django 项目 (1.3.1),并且按预期工作。
有想法吗?
谢谢!
I'm having trouble using Markdown in Django Nonrel. I followed this instructions (added 'django.contrib.markup'
to INSTALLED_APPS
, include {% load markup %}
in the template and use |markdown
filter after installing python-markdown) but I get the following error:
Error in {% markdown %} filter: The Python markdown library isn't installed.
In this line:
/path/to/project/django/contrib/markup/templatetags/markup.py in markdown
they will be silently ignored.
"""
try:
import markdown
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError("Error in {% markdown %} filter: The Python markdown library isn't installed.") ...
return force_unicode(value)
else:
# markdown.version was first added in 1.6b. The only version of markdown
# to fully support extensions before 1.6b was the shortlived 1.6a.
if hasattr(markdown, 'version'):
extensions = [e for e in arg.split(",") if e]
It seems obvious that import markdown
is causing the problem but when I run:
$ python manage.py shell
>>> import elementtree
>>> import markdown
everthing works alright.
Running Markdown 2.0.3, Python 2.7 and latest version of Django Nonrel.
UPDATE: I installed textile and it doesn't work. It produces the same error.
UPDATE 2: This is an issue related with Django Nonrel. I took an older Django project (1.3.1), and works as expected.
Ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,新手错误。
结果 Django Nonrel 找不到 markdown,因为由于某种原因,它没有安装在它正在寻找的 python 路径中。在本例中,markdown 安装在
/usr/lib/pymodules/python2.7
中,而不是/usr/local/lib/python2.7/dist-packages/
或其他一些平常的地方。所以我将 markdown 文件夹复制到 python 路径列出的位置,错误就消失了。Alright, newbie mistake.
Turns out that Django Nonrel couldn't find markdown because for some reason, it wasn't installed in a python path it was looking for. In this case, markdown was installed in
/usr/lib/pymodules/python2.7
instead of/usr/local/lib/python2.7/dist-packages/
or some other usual place. So I copied the markdown folder to a place listed by python path, and the error went away.