Skip to main content

Bootstrap4 compatible datetimepicker for Django projects.

Project description

This package uses Bootstrap v3 datetimepicker widget version 2 provided by the following project:

https://github.com/Eonasdan/bootstrap-datetimepicker

The correct formatting options for dates can be found here:

http://momentjs.com/docs/

It works only with Bootstrap3. If you are using Bootstrap2 in your Django project, check out this: https://github.com/zokis/django-bootstrap-datetimepicker

Install

  • Run pip install django-bootstrap3-datetimepicker

  • Add 'bootstrap3_datetime' to your INSTALLED_APPS

Example

forms.py

from bootstrap3_datetime.widgets import DateTimePicker
from django import forms

class ToDoForm(forms.Form):
    todo = forms.CharField(
        widget=forms.TextInput(attrs={"class": "form-control"}))
    date = forms.DateField(
        widget=DateTimePicker(options={"format": "YYYY-MM-DD",
                                       "pickTime": False}))
    reminder = forms.DateTimeField(
        required=False,
        widget=DateTimePicker(options={"format": "YYYY-MM-DD HH:mm",
                                       "pickSeconds": False}))

The options will be passed to the JavaScript datetimepicker instance. Available options are explained in the following documents:

You don’t need to set the language option, because it will be set the current language of the thread automatically.

template.html

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet"
              href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.css">
        <link rel="stylesheet"
              href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.css">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.js">
        </script>
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.js">
        </script>
        {{ form.media }}
    </head>
    <body>
        <form method="post" role="form">
            {% for field in form.visible_fields %}
            <div id="div_{{ field.html_name }}"
                 class="form-group{% if field.errors %} has-error{% endif %}">
                {{ field.label_tag }}
                {{ field }}
                <div class="text-muted pull-right">
                    <small>{{ field.help_text }}</small>
                </div>
                <div class="help-block">
                    {{ field.errors }}
                </div>
            </div>
            {% endfor %}
            {% for hidden in form.hidden_fields %}
                {{ hidden }}
            {% endfor %}
            {% csrf_token %}
            <div class="form-group">
                <input type="submit" value="Submit" class="btn btn-primary" />
            </div>
        </form>
    </body>
</html>

Bootstrap3 and jQuery have to be included along with {{ form.media }}

Release Notes

v2.3

  • Updated bootstrap-datetimepicker.js to version 3.0

v2.2.3

  • Updated bootstrap-datetimepicker.js to version 2.1.30

v2.2.3

  • Updated bootstrap-datetimepicker.js to version 2.1.30

v2.0.0

  • Includes bootstrap-datetimepicker.js version 2.1.11 with moment.js

  • The format strings have changed due to using moment.js

Requirements

  • Python >= 2.4

  • Django >= 1.3

  • Bootstrap >= 3.0

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-bootstrap4-datetimepicker-4.2.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_bootstrap4_datetimepicker-4.2-py3-none-any.whl (130.3 kB view details)

Uploaded Python 3

File details

Details for the file django-bootstrap4-datetimepicker-4.2.tar.gz.

File metadata

File hashes

Hashes for django-bootstrap4-datetimepicker-4.2.tar.gz
Algorithm Hash digest
SHA256 e6890b4386a15f4352cff610367c2b03b7a7e118c4a8e07fce2e5e313f06de92
MD5 003cc3687765c49a14bf8142c1a8bcb3
BLAKE2b-256 e9babc84754877e085065ccaadb4ee4f318e67ba306af00de2aae52b69fea1ae

See more details on using hashes here.

File details

Details for the file django_bootstrap4_datetimepicker-4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_bootstrap4_datetimepicker-4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 464a641167dd07fd33acea3954d01161df2b5e9b3a09488892afe2058bc66e8c
MD5 3f441a9a67636f3dc3ee6b061b460c3d
BLAKE2b-256 643eff557c29d9967e79b274b00070d269e51e9547bce918896e1b4af8a05a04

See more details on using hashes here.

Supported by

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