Django application to add materializecss support to django-crispy-forms
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a Django application to add django-crispy-forms template pack for Materializecss.

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 to specify which template pack to use

    CRISPY_TEMPLATE_PACK = 'materialize'

Create a form in 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

{% load crispy_forms_tags %}
<!DOCTYPE html>
<head lang="en">
    <meta charset="UTF-8">
    <!--Add materialize libraries -->
    <script src=""></script>
    <!-- Compiled and minified CSS -->
    <link rel="stylesheet"

    <!-- Compiled and minified JavaScript -->
    <script src=""></script>

    <link href=""

<div class="row">
    <div class="card-panel col m6 offset-m3">
        <!-- Only one line -->
        {% crispy form %}


Which finally leads into something like this -

![Screenshot of rendered HTML] (

Note - We did not have to write any css to style the form. It was auto-generated from the form class.