Skip to main content

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 to YYYY-MM-DD
  • DateTimePicker, which defaults to YYYY-MM-DD HH:mm:ss
  • TimePicker, which defaults to HH:mm:ss

In your Django form, you can use the widgets like this:

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.TimeField(
        widget=DateTimePicker(
            options={
                '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

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

django-tempus-dominus-0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

django_tempus_dominus-0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file django-tempus-dominus-0.1.tar.gz.

File metadata

File hashes

Hashes for django-tempus-dominus-0.1.tar.gz
Algorithm Hash digest
SHA256 1a4ea90f4252cf7c8df86c686da86b7622ec4bf88a1f951b057b8e5fb7f32a8d
MD5 6a33188423b1733430e2d7bd637946c3
BLAKE2b-256 3c7a694d4399b0134788d555f23d8ba0ae0f033d11d7ba3667ce31261824089b

See more details on using hashes here.

File details

Details for the file django_tempus_dominus-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tempus_dominus-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 269f67fc4f4fa37e03c93f5bd5c18444df74475806eeca0226da31d443a722d4
MD5 7e6ceb6a15be4223d256e1ad8751b17f
BLAKE2b-256 c2c3656c47e6d937898f47e579fa67595f20d38f1f72a27349f27a0bb710a6a3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page