Django date range form field
Project description
# django-bootstrap3-daterangepicker
This is django field wrapper for http://www.daterangepicker.com/ . Useful for reporting services.
Field data format is tuple (start_date, end_date).
Installation:
---
1. ```pip install django_bootstrap3_daterangepicker```
2. add `'django_bootstrap3_daterangepicker'` to `INSTALLED_APPS`
Usage:
----
* jQuery, Bootstrap are required on target page
```python
class PeriodFilter(forms.Form):
range = DateRangeField(widget=DateRangeWidget(picker_options={
'ranges': common_dates()
}))
# ...
form = PeriodFilter(initial={'range': (date.today(), date.today())})
# ...
(from_date, to_date) = form.cleaned_data['range']
```
Template - don't forget media:
```html
{% block extracss %}
{{ filter.media['css'] }}
{% endblock %}
{% block endscripts %}
{{ super() }}
{{ filter.media['js'] }}
{% endblock %}
{% block content %}
{{ filter.range }}
{% endblock %}
```
Special thanks to https://github.com/nkunihiko/django-bootstrap3-datetimepicker/ for guidance in creating custom fields.
This is django field wrapper for http://www.daterangepicker.com/ . Useful for reporting services.
Field data format is tuple (start_date, end_date).
Installation:
---
1. ```pip install django_bootstrap3_daterangepicker```
2. add `'django_bootstrap3_daterangepicker'` to `INSTALLED_APPS`
Usage:
----
* jQuery, Bootstrap are required on target page
```python
class PeriodFilter(forms.Form):
range = DateRangeField(widget=DateRangeWidget(picker_options={
'ranges': common_dates()
}))
# ...
form = PeriodFilter(initial={'range': (date.today(), date.today())})
# ...
(from_date, to_date) = form.cleaned_data['range']
```
Template - don't forget media:
```html
{% block extracss %}
{{ filter.media['css'] }}
{% endblock %}
{% block endscripts %}
{{ super() }}
{{ filter.media['js'] }}
{% endblock %}
{% block content %}
{{ filter.range }}
{% endblock %}
```
Special thanks to https://github.com/nkunihiko/django-bootstrap3-datetimepicker/ for guidance in creating custom fields.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django_bootstrap3_daterangepicker-1.0.0b5.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | e87674c4ed0f97de81ef30abcb99e8fcff812e03270680158c473755dbef41e5 |
|
MD5 | 753b449404036eabe6aea563c00492a0 |
|
BLAKE2b-256 | 16ab91db540bb837fbff2304ddbeb590a2973b09d5da9d4381854da87153f909 |