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.


  • From PyPI: pip install django-tempus-dominus

Then add tempus_dominus to INSTALLED_APPS in your Django settings.

Usage & Django Settings

The following settings are available:

  • TEMPUS_DOMINUS_LOCALIZE (default: False): if True, widgets will be translated to the selected browser language and use the localized date and time formats.
  • TEMPUS_DOMINUS_INCLUDE_ASSETS (default: True): if True, loads Tempus Dominus and moment JS and CSS from Cloudflare's CDN, otherwise loading the JS and CSS are up to you.

Three widgets are provided:

  • DatePicker
    • Defaults to YYYY-MM-DD
    • Defaults to L if TEMPUS_DOMINUS_LOCALIZE is True
  • DateTimePicker
    • Defaults to YYYY-MM-DD HH:mm:ss
    • Defaults to L LTS if TEMPUS_DOMINUS_LOCALIZE is True
  • TimePicker
    • Defaults to HH:mm:ss
    • Defaults to LTS if TEMPUS_DOMINUS_LOCALIZE is True

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(
                'minDate': '2009-01-20',
                'maxDate': '2017-01-20',
    time_field = forms.TimeField(
                'enabledHours': [9, 10, 11, 12, 13, 14, 15, 16],
            input_toggle: False,
    datetime_field = forms.DateTimeField(
                'minDate': ( + datetime.timedelta(days=1)).strftime('%Y-%m-%d'),  # Tomorrow
                'useCurrent': True,
                'collapse': False,
               'append': 'fa fa-calendar',
               'input_toggle': False,
               'icon_toggle': True,

Then in your template, include jQuery, {{ }}, and render the form:

    {# Include FontAwesome; required for icon display #}
    <link rel="stylesheet" href="">

    {# Include Bootstrap 4 and jQuery #}
    <link rel="stylesheet" href="" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

    {# Django Tempus Dominus assets are included in `{{ }}` #}
    {{ }}

    <div class="container">
      <div class="row">
        <div class="col">
          <form method="post" action=".">
            {% csrf_token %}
            {{ form.as_p }}

Widget Options

  • options (dictionary): This dictionary will be passed to Tempus Dominus. A full list of options is available here.
  • input_toggle (boolean, default True): Controls whether clicking on the input field toggles the datepicker popup. Typically is set to False when an icon is in use.
  • size (string): Controls the size of the input group (small or large). Defaults to the default size.
  • prepend (string): Name of a Font Awesome icon to prepend to the input field (fa fa-calendar).
  • append (string): Name of a Font Awesome icon to append to the input field (fa fa-calendar).
  • icon_toggle (boolean, default True): Controls whether clicking on the icon toggles the datepicker popup. Typically is set to False when an icon is in use.

Change Log

  • Fix a bug with duplicate DOM IDs in template.
  • Fix a bug with time formatting to use ISO time format (T12:34:56)
  • Upgrade Tempus Dominus to 5.1.2. Support for new widget attributes (size, prepend, append, input_toggle, icon_toggle, class). DatePicker now closes after losing focus, and widget attributes are properly passed.
  • Fix to ensure options are passed in proper JSON.
  • Include template in the file.
  • Add setting to exclude CDN CSS and JS assets. Add initial test suite.
  • Documentation clean up.
  • Option to l10n and i18n to all pickers.
  • 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.


Contributors & DjangoCon US Sprinters (Thank You!)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-tempus-dominus, version
Filename, size File type Python version Upload date Hashes
Filename, size django_tempus_dominus- (10.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-tempus-dominus- (7.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page