有没有办法将表单(例如反馈表单)添加到CMS中的每个页面?我真的很喜欢使用Wagtail FormBuilder,这样编辑器就可以改变字段了。
我的第一个想法是创建自定义表单页面(继承自AbstractEmailForm)作为站点根子页面,并通过模板标记将其加载到base.html。我可以通过这种方式访问页面属性,但不能呈现表单。
下面是我的模板标签:
@register.assignment_tag(takes_context=True)
def get_feedback_form(context):
return context['request'].site.root_page.get_children().type(FeedbackFormPage).first()
下面是我在base.html中使用它的方式:
{% get_feedback_form as feedback_form %}
...
{{ feedback_form.specific.title }} <-- this works
{{ feedback_form.specific.form.as_p }} <-- this doesnt work
以某种方式创建一个表单作为代码片段或将其添加到站点设置中会很好,但我不知道如何做到这一点。
https://stackoverflow.com/questions/42673180
复制相似问题