gpt4 book ai didi

python - 过滤器无效 : 'markdown' django-markdown-deux

转载 作者:行者123 更新时间:2023-12-01 01:35:22 25 4
gpt4 key购买 nike

在解释我的问题之前,让我先告诉您我的系统的一些基础知识: window 10 python 3.6Django 1.9

我跟踪了“django-markdown-deux”的文档,从中我了解到它有四个步骤要实现。

首先:pip3 install django-markdown-deux

其次:将 markdown_deux 添加到您的 INSTALLED_APPS

第三:将 {% load markdown_deux_tags %} 添加到 header.html

最后:添加{{ post.body|markdown }},因为我想将post.body转移到markdown

{% extends "personal/header.html" %}
{% block content %}

<h3><a href="/blog/{{post.id}}">{{ post.title }}</a></h3>
<h6> on {{ post.date }}</h6>

<div class = "container">
{{ post.body|markdown }}
</div>
<br><br>
{% endblock %}

执行此操作后,我出现“模板渲染期间出错”

In template F:\django\mysite_1\blog\templates\blog\post.html, error at line 8

Invalid filter: 'markdown'

最佳答案

您需要在使用标签的模板文件中加载标签(而不是在 header.html 中)。换句话说,您需要在调用 {{ post.body|markdown }} 的同一文件中包含 {% load markdown_deux_tags %}:

{% extends "personal/header.html" %}
{% load markdown_deux_tags %}
{% block content %}

<h3><a href="/blog/{{post.id}}">{{ post.title }}</a></h3>
<h6> on {{ post.date }}</h6>

<div class = "container">
{{ post.body|markdown }}
</div>
<br><br>
{% endblock %}

关于python - 过滤器无效 : 'markdown' django-markdown-deux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52439632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com