Git Product home page Git Product logo

django-materializecss-form's Introduction

materialize-css-form

Materializecss for Django Form

A simple Django template tag to work with Materializecss

Install

pip install  django-materializecss-form

on pypi on GitHub

Add to INSTALLED_APPS:

INSTALLED_APPS = (
     'materializecssform',
     ...
     )

Add Materializecss to your project:

In your base.html:

<head>

{% block css %}
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.1/css/materialize.min.css" integrity="sha256-qj3p6P1fJIV+Ndv7RW1ovZI2UhOuboj9GcODzcNFIN8=" crossorigin="anonymous" />
{% endblock css %}

</head>

  <body >

  {% block javascript %}
  <script
    src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
    crossorigin="anonymous"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.1/js/materialize.min.js" integrity="sha256-SrBfGi+Zp2LhAvy9M1bWOCXztRU9Ztztxmu5BcYPcPE=" crossorigin="anonymous"></script>

  <script>
  $(document).ready(function(){

    // Initialize materialize data picker
    $('.datepicker').datepicker({'format': 'yyyy-mm-dd'});
    $('select').formSelect();

  });

  </script>

  {% endblock javascript %}



  ...

  </body>

Usage

Use it like this, simple.

{% load materializecss %}

All the form

{{ form|materializecss }}

Individual field

{{ form.<> | materializecss }}

Custom size (default is 's12')

{{ form|materializecss:'m6' }}

Icons support

This is most useful for adding a descriptive icon when you are creating a custom layout by building the form one field at a time. Substitue FIELD_NAME below with one of the field names from your form.

{{ form.FIELD_NAME|materializecss:'s12 m6, icon=person' }}
{{ form.FIELD_NAME|materializecss:'custom_size=s12 m6, icon=person' }}

Demo

Basic form

DatePicker

Help

Widget

  • TextInput
  • Textarea
  • CheckboxInput
  • RadioSelect
  • Select
  • SelectMultiple
  • CheckboxSelectMultiple
  • Filefield
  • DateField
  • DateTimeField (doesn't show time yet)

Inspired by

django-bootstrap-form

Originally Built By

Florent CLAPIÉ

[https://pypi.org/user/florent1933/] https://pypi.org/user/florent1933/

django-materializecss-form's People

Contributors

kalwalkden avatar dwjorgeb avatar mrokita avatar michaelmarziani avatar patrys avatar aabele avatar akinadebowale avatar florent1933 avatar gabrielwolf avatar gacha20 avatar krzysztofwolski avatar rosslyoung avatar

Watchers

Alexander Diana avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.