在django中,我使用jinja模板语言和django-widget-tweaks为用户创建表单实现了自定义视图。但是在表单中,密码字段的帮助文本是列表项,它以原始文本的形式呈现。有办法解决这个问题。
here is the image which shows the ul element rendering as raw text
{% extends 'base.html' %} {% block head %}
<title>Register</title>
{% endblock %} {% block body %}
{% load widget_tweaks %}
<div class="fs-container">
<form method='post' class="form-signin">
{% csrf_token %}
{% for hidden_field in form.hidden_fields %}
{{ hidden_field }}
{% endfor %}
{% if form.non_field_errors %}
<div class="alert alert-danger" role="alert">
{% for error in form.non_field_errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% for field in form.visible_fields %}
<div class="form-group">
<!-- {{ field.label_tag }} -->
{% if form.is_bound %}
{% if field.errors %}
{% render_field field class="form-control is-invalid" %}
{% for error in field.errors %}
<div class="invalid-feedback">
{{ error }}
</div>
{% endfor %}
{% else %}
{% render_field field class="form-control is-valid" placeholder=field.label %}
{% endif %}
{% else %}
{% render_field field class="form-control" placeholder=field.label %}
{% endif %}
{% if field.help_text %}
<small class="form-text text-muted">{{ field.help_text }}</small>
{% endif %}
</div>
{% endfor %}
<button type="submit" class="btn btn-lg btn-primary btn-block cs-btn">Register</button>
</form>
</div>
{% endblock %}