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
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
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(
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>
Maintainer
- Timothy Allen (https://github.com/FlipperPA)
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-0.1.1.tar.gz
.
File metadata
- Download URL: django-tempus-dominus-0.1.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df71b1dca960c74b3b970481d6e26f9ccee934381465ad4296f3beaef40a32a |
|
MD5 | a3e81fcc7751722d8ec3903a0a40697b |
|
BLAKE2b-256 | adf55f1341b2c7fb65c31d38f8b5916d4872cf360f525e4596a2517b4103b6e0 |
File details
Details for the file django_tempus_dominus-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: django_tempus_dominus-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b93c6f9effa8ef2b6bb9210c316c7573c5fc1325f8f8cc92d8e3cb35dcf19358 |
|
MD5 | 390cc84b1bb0589a1ea8a7598dd160e6 |
|
BLAKE2b-256 | 50ab04e0186b7a346d2077277e005ba05a9f6a25507c58facd1e97c4b9a868db |