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 >= 3.2.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
File details
Details for the file django-bootstrap-daterangepicker-1.1.0.tar.gz
.
File metadata
- Download URL: django-bootstrap-daterangepicker-1.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b3ce348476d1b11191762d6ad98e0014d545c69f40e8db15bbc7abc94269cf |
|
MD5 | a573afd94006ff2efa30c30eed3318e1 |
|
BLAKE2b-256 | 68b8c73a542dee1dc254f8177c67afcf3d734c787beb2a7882e962386f4b9480 |
File details
Details for the file django_bootstrap_daterangepicker-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_bootstrap_daterangepicker-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6a82eba823edeefdedc229475c40554dd907e0d0d6f8c762ae8145737a57168 |
|
MD5 | c55c2f942fda0520da50ce2ccf6c8e65 |
|
BLAKE2b-256 | 60a47e02293a40a71076c6a5b27227e9977e818d747409114609b8a1f96fdf43 |