A Django widget for the Tempus Dominus Bootstrap 4 DateTime picker.
Project description
Django Tempus Dominus
Django Tempus Dominus provides Django widgets for the Tempus Dominus Bootstrap 4 DateTime date and time picker. Why yet another date and time picker for Django? None supported the Tempus Dominus date and time picker, which is actively developed and feature rich. It is a successor to the popular bootstrap-datetimepicker
JavaScript library.
Installation
-
From PyPI:
pip install django-tempus-dominus
-
From source:
git clone git+https://github.com/FlipperPA/django-tempus-dominus.git
pip install -e django-tempus-dominus
Usage & Settings
Three widgets are provided:
DatePicker
, which defaults toYYYY-MM-DD
DateTimePicker
, which defaults toYYYY-MM-DD HH:mm:ss
TimePicker
, which defaults toHH:mm:ss
A Django setting is provided for locaized date and time:
TEMPUS_DOMINUS_LOCALIZE
(default: False): if True, widgets will be translated to the selected browser language and use the localized date and time formats.
In your Django form, you can use the widgets like this:
import datetime
from django import forms
from tempus_dominus.widgets import DatePicker, TimePicker, DateTimePicker
class MyForm(forms.Form):
date_field = forms.DateField(widget=DatePicker())
date_field_required_with_min_max_date = forms.DateField(
required=True,
widget=DatePicker(
options={
'minDate': '2009-01-20',
'maxDate': '2017-01-20',
}
),
)
time_field = forms.TimeField(
widget=TimePicker(
options={
'enabledHours': [9, 10, 11, 12, 13, 14, 15, 16],
}
),
)
datetime_field = forms.DateTimeField(
widget=DateTimePicker(
options={
'minDate': (datetime.date.today() + datetime.timedelta(days=1)).strftime('%Y-%m-%d'), # Tomorrow
'useCurrent': True,
'collapse': False,
}
),
)
The options
dictionary will be passed to Tempus Dominus. A full list of options is available here.
Then in your template, include jQuery, {{ form.media }}
, and render the form:
<html>
<head>
<script crossorigin="anonymous" integrity="sha384-xBuQ/xzmlsLoJpyjoggmTEz8OWUFM0/RC5BsqQBDX2v5cMvDHcMakNTNrHIW2I5f" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
{{ form.media }}
</head>
<body>
<form method="post" action=".">
{% csrf_token %}
{{ form.as_p }}
</form>
</body>
</html>
Change Log
- 5.0.1.1: Option to l10n and i18n to all pickers (thank you, @AxTheB).
- 5.0.1.0: Upgrade to Tempus Dominus full release version
5.0.1
. Fix bug for populating initial values (thank you, @ianastewart). - 0.1.2: UX enhancement: auto-dismiss dialog if the input loses focus.
- 0.1.1: Bug fixes.
- 0.1.0: Initial release.
Maintainer
- Timothy Allen (https://github.com/FlipperPA)
Contributors (Thank You!)
- Ian Stewart (https://github.com/ianastewart)
- Václav 'ax' Hůla (https://github.com/AxTheB)
- waymou (https://github.com/waymao)
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
Built Distribution
File details
Details for the file django-tempus-dominus-5.0.1.1.tar.gz
.
File metadata
- Download URL: django-tempus-dominus-5.0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0caf69fd210d9cbdcbff025b082e5fcaa39d1fd1ec4238163d6373d4c76bf590 |
|
MD5 | 28f14eb020800210e6150afa13161861 |
|
BLAKE2b-256 | 7ac6a1dacb6a47f34068d0d6960dbf332e282161042d5dc7d6f24d082c139e8c |
File details
Details for the file django_tempus_dominus-5.0.1.1-py3-none-any.whl
.
File metadata
- Download URL: django_tempus_dominus-5.0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28cb051da6aabb828cc64e241f4a8cf2dbf45cd62c5553588d2e556d5ea0e3b7 |
|
MD5 | 6e388d91483183e7ec053f04704fec75 |
|
BLAKE2b-256 | 9e31c572e5ee30f45192924c5c796f2743e71946c9ee53d39836dc56f5232fce |