【发布时间】:2020-04-03 07:14:03
【问题描述】:
//form.html
{% load crispy_forms_tags %}
{% block content %}
<form {% if form_id %} id='{{ form_id }}' {% endif %} class='form' method='POST' action="{% if action_url %}{{ action_url }}{% endif %}">
{% csrf_token %}
{{ form|crispy }}
<input class="btn btn-primary" type="submit" value="{{ btn_title }}" />
</form>
{% endblock %}
//list_view.html
{% extends "base.html" %}
{% block content %}
<div class="row">
<div class='col-sm-3 col-xs-12' style='background-color:red;'>
<h1>{{ request.user }}</h1>
</div>
<div class='col-sm-9 '>
{% if not request.GET.q %}
<div class="">
{% include "tweets/form.html" with form=create_form action_url=create_url
btn_title='Tweet' form_id='tweet-form' %}
</div>
<hr>
{% endif %}
<div id="tweet-container">
</div>
</div>
</div>
{% endblock content %}
由于某种原因,当我尝试在 list_view.html 的块内容中使用 form.html 时,它只返回 {% include "tweets/form.html" with form=create_form action_url=create_url btn_title='Tweet' form_id='tweet-form' %} 正如你在我发布的照片中看到的那样。我试图使它成为一个带有提交按钮的文本区域。有没有人有什么建议
【问题讨论】:
标签: html django django-rest-framework django-templates