title: Error: 'bool' object has no attribute 'startswith' when I use django-smart-select
body: <p>I recieved the error <code>bool</code> object has no attribute <code>startswith</code> when I changed two fields in model <code>Location</code>. I tried to use django-smart-select.(<code>ChainedForeignKey</code>)</p>
  
  <pre><code> from smart_selects.db_fields import ChainedForeignKey 
   class ListOfContinents(models.Model):
  
      id_Continent = models.AutoField(primary_key=True)
      Continent = models.CharField(max_length=200,unique=True) 
  
      def __str__(self):
          return '%s' % self.Continent
  
  class ListOfCountries(models.Model):
  
      id_Country = models.AutoField(primary_key=True)
      Continent = models.ForeignKey(
          ListOfContinents, default=0, to_field='Continent',db_column='Continent')
      Country=models.CharField(max_length=200,unique=True)
  
      def __str__(self):
          return '%s' % self.Country
  
  
  
  class Location(models.Model):
  
      #Continent=models.CharField(max_length=200,null=True, verbose_name='Континент')
      #Country=models.CharField(max_length=200,null=True, verbose_name='Страна')
      Continent=models.ForeignKey(
          ListOfContinents,to_field='Continent',
          db_column='Continent',verbose_name='Континент',null=True)
      Country = ChainedForeignKey(ListOfCountries,chained_field="Continent",
          chained_model_field="Continent",
          show_all=False,
          auto_choose=True,
          sort=True, 
          verbose_name='Страна',
          db_column='Country',
          to_field='Country',
          null=True)
  </code></pre>
  
  <p>Forms.py</p>
  
  <pre><code>class LocationForm (forms.ModelForm):
      class Meta:
          model = Location
          fields = ('Continent','Country')
  
      def __init__(self, *args, **kwargs):
          self.helper = FormHelper()
          self.helper.form_id = 'id-unitForm'
          # self.helper.form_class = 'blueForms'
          self.helper.form_class = 'form-horizontal'
          self.helper.label_class = 'col-lg-1'
          self.helper.field_class = 'col-lg-4'
          self.helper.form_method = 'post'
          # self.helper.form_action = 'submit_survey'
  
          self.helper.add_input(Submit('submit', 'Submit', css_class='btn btn-primary'))
          self.helper.add_input(Button('cancel', 'Cancel', css_class='btn-default', onclick="window.history.back()"))
  
          super(LocationForm, self).__init__(*args, **kwargs)
  </code></pre>
  
  <p>Full error text:  </p>
  
  <blockquote>
    <p>'bool' object has no attribute 'startswith'
    site-packages\crispy_forms\templates\bootstrap3\uni_form.html, error
    at line 4</p>
  </blockquote>
  
  <p>Line 4:</p>
  
  <pre><code>{% if include_media %}
  {{ form.media }}
  {% endif %}
  </code></pre>
  
  <p>Please help me to solve thos error. 
  Thanks!</p>
  
  <pre><code>class Media(object):
      def __init__(self, media=None, **kwargs):
          if media:
              media_attrs = media.__dict__
          else:
              media_attrs = kwargs
  
          self._css = {}
          self._js = []
  
          for name in MEDIA_TYPES:
              getattr(self, 'add_' + name)(media_attrs.get(name, None))
  
          # Any leftover attributes must be invalid.
          # if media_attrs != {}:
          #     raise TypeError("'class Media' has invalid attribute(s): %s" % ','.join(media_attrs.keys()))
  
      def __str__(self):
          return self.render()
  
      def render(self):
          return mark_safe('\n'.join(chain(*[getattr(self, 'render_' + name)() for name in MEDIA_TYPES])))
  
      def render_js(self):
          return [format_html('&lt;script type="text/javascript" src="{0}"&gt;&lt;/script&gt;', self.absolute_path(path)) for path in self._js]
  
      def render_css(self):
          # To keep rendering order consistent, we can't just iterate over items().
          # We need to sort the keys, and iterate over the sorted list.
          media = sorted(self._css.keys())
          return chain(*[
              [format_html('&lt;link href="{0}" type="text/css" media="{1}" rel="stylesheet" /&gt;', self.absolute_path(path), medium)
               for path in self._css[medium]]
              for medium in media])
  
      def absolute_path(self, path, prefix=None):
          if path.startswith(('http://', 'https://', '/')):
              return path
          if prefix is None:
              if settings.STATIC_URL is None:
                  # backwards compatibility
                  prefix = settings.MEDIA_URL
              else:
                  prefix = settings.STATIC_URL
          return urljoin(prefix, path)
  
      def __getitem__(self, name):
          "Returns a Media object that only contains media of the given type"
          if name in MEDIA_TYPES:
              return Media(**{str(name): getattr(self, '_' + name)})
          raise KeyError('Unknown media type "%s"' % name)
  
      def add_js(self, data):
          if data:
              for path in data:
                  if path not in self._js:
                      self._js.append(path)
  
      def add_css(self, data):
          if data:
              for medium, paths in data.items():
                  for path in paths:
                      if not self._css.get(medium) or path not in self._css[medium]:
                          self._css.setdefault(medium, []).append(path)
  
      def __add__(self, other):
          combined = Media()
          for name in MEDIA_TYPES:
              getattr(combined, 'add_' + name)(getattr(self, '_' + name, None))
              getattr(combined, 'add_' + name)(getattr(other, '_' + name, None))
          return combined
  </code></pre>