Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bootstrap_datepicker.widgets import DatePicker
- class DateInput(DatePicker):
- def __init__(self):
- DatePicker.__init__(self,format="%Y-%m-%d")
- def build_attrs(self, attrs, extra_attrs=None, **kwargs):
- attrs = dict(self.attrs, **kwargs)
- if extra_attrs:
- attrs.update(extra_attrs)
- return attrs
- class LodgingOfferForm(forms.ModelForm):
- class Meta:
- widgets = {
- 'check_in': DateInput(),
- 'check_out': DateInput(),
- }
- model = LodgingOffer
- fields = ('other fields', 'check_in', 'check_out', )
- {% load bootstrap3 %}
- {% block body_content %}
- {% block extrahead %} {# Extra Resources Start #}
- {{ form.media }} {# Form required JS and CSS #}
- {% endblock %}
- {% bootstrap_field form.check_in %}
- {% bootstrap_field form.check_out %}
- {% endblock %}
- class Meta:
- widgets = {
- 'check_in': DateInput(),
- 'check_out': DateInput(),
- }
- model = LodgingOffer
- fields = ('check_in', 'check_out', )
- def __init__(self, *args, **kwargs):
- super(LodgingOfferForm, self).__init__(*args, **kwargs)
- self.fields['check_in'].widget.attrs['class'] = 'input-group input-daterange'
- self.fields['check_out'].widget.attrs['class'] = 'input-group input-daterange'
- <script>
- $('.input-daterange input').each(function() {
- $(this).datepicker('clearDates');
- });
- </script>
Add Comment
Please, Sign In to add comment