The main goal of this project is to reduce the time spent by developers on styling forms. Since most of the time we are using a css framework, the work done in styling different forms is quite redundant and boring. This library aims at reducing this redundancy by automatically sytling your forms using the Materializecss framework.
How To Use
Add the following code to settings.py to specify which template pack to use
CRISPY_TEMPLATE_PACK = 'materialize'
Create a form in forms.py and override its init to add FormHelper as the helper.
class TestForm(forms.Form): username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput) def __init__(self, *args, **kwargs): super(TestForm, self).__init__(*args, **kwargs) self.helper = FormHelper()
Associate it with a view
class RegisterView(FormView): form_class = TestForm template_name = 'test.html'
And finally the template
Which finally leads into something like this -
![Screenshot of rendered HTML] (https://raw.githubusercontent.com/utkbansal/crispy-forms-materialize/master/Screenshot.png)
Note - We did not have to write any css to style the form. It was auto-generated from the form class.