Created
May 28, 2012 20:15
-
-
Save eguevara2012/2821026 to your computer and use it in GitHub Desktop.
Datepicker template for Django-Crispy-Forms
This file contains 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
# Template for rendering the datepicker with Django-Crispy-Forms | |
# datepicker.html | |
{% load crispy_forms_field %} | |
<div id="div_{{ field.auto_id }}" class="clearfix control-group{% if field.errors %} error{% endif %}"> | |
{% if field.label %} | |
<label for="id_{{ field.id_for_label }}" class="control-label {% if field.field.required %}requiredField{% endif %}"> | |
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %} | |
</label> | |
{% endif %} | |
<div class="controls"> | |
<div id="{{ field.auto_id }}" class="input-append date" data-date="{% now 'd-m-Y' %}" data-date-format="dd-mm-yyyy"> | |
{% crispy_field field %}<span class="add-on"><i class="icon-calendar"></i></span> | |
{% include 'bootstrap/layout/field_errors.html' %} | |
</div> | |
{% include 'bootstrap/layout/help_text.html' %} | |
</div> | |
</div> | |
# In forms.py | |
def __init__(self, *args, **kwargs): | |
self.helper = FormHelper() | |
Fieldset( | |
[...] | |
Field('date_start', css_class='input-small' , readonly='readonly', id="date_start", template='project/util/datepicker.html'), | |
Field('date_end', id='date_end', css_class='input-small', readonly='readonly' ,template='project/util/datepicker.html'), | |
) | |
# CSS Style for asterisk(*) | |
span.asteriskField { | |
color: red; | |
font-size: 15px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment