Date Picker
Last Updated: August 10, 2015
- class tethys_sdk.gizmos.DatePicker(name, display_text='', autoclose=False, calendar_weeks=False, clear_button=False, days_of_week_disabled='', end_date='', format='', min_view_mode='days', multidate=1, start_date='', start_view='month', today_button=False, today_highlight=False, week_start=0, initial='', disabled=False, error='', attributes=None, classes='')
Date pickers are used to make the input of dates streamlined and easy. Rather than typing the date, the user is presented with a calendar to select the date. This date picker was implemented using Bootstrap Datepicker.
- calendar_weeks
Set whether calendar week numbers are shown on the left of the datepicker.
- Type:
bool
- days_of_week_disabled
Days of the week that are disabled 0-6 with 0 being Sunday and 6 being Saturday. Multiple days are comma separated (e.g.: '0,6').
- Type:
str
- end_date
Last date that can be selected. All other dates after this date are shown as disabled.
- Type:
str
- format
String representing date format. For valid formats see Bootstrap Datepicker documentation here.
- Type:
str
- start_date
First date that can be selected. All other dates before this date are shown as disabled.
- Type:
str
- start_view
View the date picker starts on. Valid values include 'month', 'year', and 'decade'.
- Type:
str
- attributes
A dictionary representing additional HTML attributes to add to the primary element (e.g. {"onclick": "run_me();"}).
- Type:
dict
- classes
Additional classes to add to the primary HTML element (e.g. "example-class another-class").
- Type:
str
Controller Example
pythonfrom tethys_sdk.gizmos import DatePicker # Date Picker Options date_picker = DatePicker(name='date1', display_text='Date', autoclose=True, format='MM d, yyyy', start_date='2/15/2014', start_view='decade', today_button=True, initial='February 15, 2014') date_picker_error = DatePicker(name='data2', display_text='Date', initial='10/2/2013', disabled=True, error='Here is my error text.') context = { 'date_picker': date_picker, 'date_picker_error': date_picker_error, }
Template Example
python{% load tethys_gizmos %} {% gizmo date_picker %} {% gizmo date_picker_error %}