A Django form field and widget wrapper for bootstrap-daterangepicker
Project description
django-bootstrap-daterangepicker
This is Django form field wrapper for bootstrap-daterangepicker, for use with Bootstrap 3 and 4.
This module allows for: single date pickers, date range selectors and datetime range selectors.
Ranges are returned as tuples of format (start, end)
, where start
and end
are datetime.date or datetime.datetime objects depending on the field type.
The DateField is a replacement for Django's built-in forms.DateField
, with the only difference being that it accepts an optional clearable
parameter, and the default widget is the DatePickerWidget specified in this module.
Installation
pip install django-bootstrap-daterangepicker
- Add
'bootstrap_daterangepicker'
to yourINSTALLED_APPS
- Add the resource links required for bootstrap-daterangepicker into the
<head>
of the relevant HTML files
Example usage
from django import forms
from bootstrap_daterangepicker import widgets, fields
class DemoForm(forms.Form):
# Date Picker Fields
date_single_normal = fields.DateField()
date_single_with_format = fields.DateField(
input_formats=['%d/%m/%Y'],
widget=widgets.DatePickerWidget(
format='%d/%m/%Y'
)
)
date_single_clearable = fields.DateField(required=False)
# Date Range Fields
date_range_normal = fields.DateRangeField()
date_range_with_format = fields.DateRangeField(
input_formats=['%d/%m/%Y'],
widget=widgets.DateRangeWidget(
format='%d/%m/%Y'
)
)
date_range_clearable = fields.DateRangeField(required=False)
# DateTime Range Fields
datetime_range_normal = fields.DateTimeRangeField()
datetime_range_with_format = fields.DateTimeRangeField(
input_formats=['%d/%m/%Y (%I:%M:%S)'],
widget=widgets.DateTimeRangeWidget(
format='%d/%m/%Y (%I:%M:%S)'
)
)
datetime_range_clearable = fields.DateTimeRangeField(required=False)
Requirements
- Bootstrap >= 3
- jQuery >= 1
- Moment.js >= 2.10.6
- bootstrap-daterangepicker >= 2
- Django >= 1.8
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-bootstrap-daterangepicker-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75d485a2cc7ce38594f33df92a75c54a0ac307d2814d3b71e337500b56235644 |
|
MD5 | 2f5607cf934ff4fee0d1bd0c060d93ea |
|
BLAKE2b-256 | 064c6770d0200dcc541cdea42695ca971ee467ef8ff62874801e66454d23eceb |
Hashes for django_bootstrap_daterangepicker-1.0.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 450cf94052cf7a39897e1d502b8c0b61292528f11fe252067c1e2aea1c626f2b |
|
MD5 | 2c3e4c91bfc096d78eec87f12ea4739a |
|
BLAKE2b-256 | f3692678bb2ffdcc5ce6c7ce20877ac8d11713d72cb3584360c65cb5bf15959e |