Created
March 27, 2017 21:15
-
-
Save MandarGogate/3472cb24f4b3a4ba9a6ca3fd371bf75e to your computer and use it in GitHub Desktop.
Django Bootstrap Parsley (pip install django-bootstrap3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="/static/parsleyjs/dist/parsley.min.js"></script> | |
{% load bootstrap3 %} | |
<form class="form-horizontal form-label-left" data-parsley-validate> | |
{%bootstrap_form form layout='horizontal'%} | |
<div class="form-group"> | |
<div class="col-md-6 col-md-offset-3"> | |
<button type="reset" class="btn btn-primary">Reset</button> | |
<button id="send" type="submit" class="btn btn-success">Submit</button> | |
</div> | |
</div> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from parsley.decorators import parsleyfy | |
@parsleyfy | |
class ContactForm(forms.Form): | |
name = forms.CharField(min_length=3, max_length=30) | |
url = forms.URLField() | |
url2 = forms.URLField(required=False) | |
email = forms.EmailField() | |
class Meta: | |
parsley_extras = { | |
'email': { | |
'minlength': "5", | |
}, | |
'email2': { | |
'equalto': "email", | |
'error-message': "Your email do not match.", | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = ( | |
'parsley', | |
'bootstrap3', | |
) | |
BOOTSTRAP3 = { | |
# Label class to use in horizontal forms | |
'horizontal_label_class': 'item form-group control-label col-md-3 col-sm-3 col-xs-12', | |
# Field class to use in horizontal forms | |
'horizontal_field_class': 'item form-group col-md-7 col-xs-12', | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment