首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >django-filter:样式选择文件

django-filter:样式选择文件
EN

Stack Overflow用户
提问于 2014-12-24 15:28:38
回答 1查看 1.5K关注 0票数 5

我已经创建了django-filter,以便在django-table2上执行列过滤,但我仍然无法设置生成的下拉列表的样式,以便与整个页面样式相匹配

-I正在使用Bootsrap3

请发布任何解决此问题的建议,或者我是否应该使用常规django表单进行列过滤

这是我的过滤器类表单filter.py

代码语言:javascript
复制
Pi_FILTER_CHOICES= (('', 'Select PI#'),(1,"PI1"),(2,"PI2"),(3,"PI3"),)
class PI_NameFilter(filters.FilterSet):
    pi_name = filters.ChoiceFilter( label = "PI Name", choices=Pi_FILTER_CHOICES)
    class Meta:
        modle = SamplesLinkage

这是我模板上的过滤器

代码语言:javascript
复制
{% block filter %}
<form action="" method="get">
      <label for="id_pi_name">Search by PI:  </label>
      {{ filter.form.pi_name }}
      <button type="submit" class="btn btn-default btn-sm">
          <span class="glyphicon glyphicon-search" aria-hidden="true"></span> Go Find
      </button>

 </form>
 {% endblock %} 
EN

回答 1

Stack Overflow用户

发布于 2017-08-17 23:59:03

您(或者至少是将来仍然面临此问题的任何人)将必须使用以下文档手动呈现表单域:https://docs.djangoproject.com/en/1.11/topics/forms/#rendering-fields-manually

代码语言:javascript
复制
{{ form.non_field_errors }}
<div class="fieldWrapper">
    {{ form.subject.errors }}
    <label for="{{ form.subject.id_for_label }}">Email subject:</label>
    {{ form.subject }}
</div>
<div class="fieldWrapper">
    {{ form.message.errors }}
    <label for="{{ form.message.id_for_label }}">Your message:</label>
    {{ form.message }}
</div>
<div class="fieldWrapper">
    {{ form.sender.errors }}
    <label for="{{ form.sender.id_for_label }}">Your email address:</label>
    {{ form.sender }}
</div>
<div class="fieldWrapper">
    {{ form.cc_myself.errors }}
    <label for="{{ form.cc_myself.id_for_label }}">CC yourself?</label>
    {{ form.cc_myself }}
</div>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27633188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档