title: Handle django-filter form with split fields using django-crispy-forms
body: <p>I have a <a href="http://django-tables2.readthedocs.org/en/latest/" rel="nofollow noreferrer">django-tables2</a> table that is being filtered with <a href="http://django-filter.readthedocs.org/en/latest/" rel="nofollow noreferrer">django-filter</a>. I have implemented a scheme based on  <strong>option D</strong> from <a href="https://stackoverflow.com/a/15129259/666823">this great answer</a>.</p>
  
  <p>However, I am using <a href="http://django-crispy-forms.readthedocs.org/en/latest/" rel="nofollow noreferrer">django-crispy-forms</a> with bootstrap3 for my form rendering. This works great until I want to apply a <a href="http://django-filter.readthedocs.org/en/latest/ref/filters.html#rangefilter" rel="nofollow noreferrer">RangeFilter</a>, which spits out two fields (a min and max field).</p>
  
  <p>The output I get is <img src="https://i.stack.imgur.com/6BoLQ.png" alt="Resultant crazy price field"></p>
  
  <p>I would like to control each of those fields manually so that I could PrependedAppendedText them separately.</p>
  
  <p>Any ideas?</p>
  
  <p><strong><em>views.py</em></strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from crispy_forms.bootstrap import PrependedAppendedText, FormActions
  from crispy_forms.helper import FormHelper
  from crispy_forms.layout import Layout, Submit, Button
  from django_tables2 import SingleTableView
  from aids.filters import AidFilter
  import os
  
  class FilteredSingleTableView(SingleTableView):
      filter_class = None
  
      def get_table_data(self):
          self.filter = AidFilter(
              self.request.GET,
              queryset=super(FilteredSingleTableView, self).get_table_data(),
          )
          self.filter.helper = FormHelper()
          self.filter.helper.form_id = 'id_filterForm'
          self.filter.helper.form_class = 'form-inline'
          self.filter.helper.form_method = 'get'
          self.filter.helper.form_tag = True
          self.filter.helper.field_template = os.path.join('bootstrap3', 'layout', 'inline_field.html')
  
          self.filter.helper.layout = Layout(
              'name',
              PrependedAppendedText('price', '$', 'min', ),
              # Fieldset(
                  # 'Filter by price',
                  # PrependedAppendedText('price_0', '$', 'min', id='id_price_0'),
                  # PrependedAppendedText('price_1', '$', 'max', id='id_price_1'),
              # ),
              'maint',
              'post',
              'supplier',
              FormActions(
                  Submit('submit_filter', 'Filter', css_class='btn-primary'),
                  Button('clear', 'Clear', css_class='btn-sm')
              )
          )
  
          return self.filter
  
      def get_context_data(self, **kwargs):
          context = super(FilteredSingleTableView, self).get_context_data(**kwargs)
          context['filter'] = self.filter
          return context
  </code></pre>
  
  <p><strong><em>filters.py</em></strong></p>
  
  <pre class="lang-py prettyprint-override"><code>import django_filters
  from aids.models import Aid
  
  class AidFilter(django_filters.FilterSet):
      name = django_filters.CharFilter(lookup_type='contains')
      price = django_filters.RangeFilter()
  
      class Meta:
          model = Aid
          fields = ['name', 'price', 'maint', 'post', 'supplier']
  </code></pre>
  
  <p><strong><em>view_table.html</em></strong></p>
  
  <pre class="lang-html prettyprint-override"><code>{% extends 'base.html' %}
  
  {% block title %}{{ title }}{% endblock %}
  
  {% block extra_css %}
      &lt;link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" /&gt;
  {% endblock %}
  
  {% load render_table from django_tables2 %}
  {% load crispy_forms_tags %}
  
  {% block heading %}
      {{ title }}
  {% endblock %}
  
  {% block content %}
      {% crispy filter.form filter.helper %}
      {% render_table table %}
  {% endblock %}
  </code></pre>
  
  <p><strong><em>urls.py</em></strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from django.conf.urls import patterns, include, url
  from django.conf.urls.static import static
  from django.contrib import admin
  from aids.filters import AidFilter
  from aids.models import Aid
  from aids.tables import AidTable
  from sadb import settings
  from aids.views import FilteredSingleTableView
  
  admin.autodiscover()
  
  urlpatterns = patterns('',
      url(r'^admin/', include(admin.site.urls)),
      url(r'^aid_form/', 'aids.views.aid_form'),
      url(r'^supplier_form/', 'aids.views.supplier_form'),
      url(r'^view_aids/', 'aids.views.view_aids'),
      url(
          r'^$', FilteredSingleTableView.as_view(
              model=Aid,
              table_class=AidTable,
              template_name='view_table.html',
              filter_class=AidFilter
          ), name='filtered_view'
      ),
  ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>