我有两个模板,一个是base.html,其中有一个要显示给其余模板的报告问题按钮。单击报告问题按钮后,将显示Bootstrap模式。我有一个下拉列表,从中可以选择要报告问题的课程。我可以在下拉列表中获取课程,但是当我使用其他模板时,我不想显示下拉列表,而是自动填写课程名称在下拉菜单下方的输入中。我的问题是我应该如何在另一个模板中隐藏下拉菜单并显示输入标签代替它?在Django中这可能吗?
{% if not user.profile.is_moderator and user.is_authenticated %}
<button type="button" class="feedback-button" data-toggle="modal" data-target="#myModal"><i class="fa fa-question-circle" aria-hidden="true"></i> Report Issue</button>
{% endif %}
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Leave us a message</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form role="form" method="POST" action="">
{% csrf_token %}
<p>Send your message in the form below and we will get back to you as early as possible.</p>
<div class="form-group">
<label for="user_name">User:</label>
<input type="text" name="user_name" class="form-control" id="user_name" value="{{user.username}}" disabled>
<label for="user_email">Email:</label>
<input type="text" name="user_email" class="form-control" id="user_email" value="{{user.email}}" disabled>
<label for="course_name">Course: </label>
<select class="form-control">
{% for course in courses %}
<option>
{% if course.data %}
{{course.data}}
{% else %}
{{course}}
{% endif %}
</option>
{% endfor %}
</select>
<br>
<input type="text" value="{{course.name}}" class="form-control" id="user_course" name="user_course">
<label for="message">Message:</label>
<input type="text" name="message" class="form-control" id="message" required>
</div>
<button type="submit" class="btn btn-lg btn-success btn-block" id="btnMessage">Send →</button>
</form>
</div>
</div>
</div>
</div>