Question

I am trying to create a crispy form that looks something like this, but my code renders a default html input box and a disjoint bootstrap button instead of the desired, "connected" form. My form code looks something like:

class SearchForm(forms.Form):
    query = forms.CharField()    
    def __init__(self, *args, **kwargs):
        super(SearchForm, self).__init__(*args, **kwargs)
        self.fields['query'].label = ""
        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            FieldWithButtons('query', StrictButton(">>", type="submit", css_class="btn-success"), css_class='input-xlarge')
        )
        self.helper.form_tag = False

It creates something that looks like this. How do I fix this?

Was it helpful?

Solution

Looks like you want Bootstrap. Try setting CRISPY_TEMPLATE_PACK = 'bootstrap' (or bootstrap3) in your settings.py, as per this documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top