Skip to main content

Bootstrap3 compatible datetimepicker for Django2/dPAC project.

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

dpac-datetimepicker-3.1.1.tar.gz (74.9 kB view details)

Uploaded Source

Built Distributions

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

dpac_datetimepicker-3.1.1-py3.7.egg (120.6 kB view details)

Uploaded Egg

dpac_datetimepicker-3.1.1-py3.6.egg (120.8 kB view details)

Uploaded Egg

dpac_datetimepicker-3.1.1-py2.7.egg (120.7 kB view details)

Uploaded Egg

File details

Details for the file dpac-datetimepicker-3.1.1.tar.gz.

File metadata

  • Download URL: dpac-datetimepicker-3.1.1.tar.gz
  • Upload date:
  • Size: 74.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/3.6.5

File hashes

Hashes for dpac-datetimepicker-3.1.1.tar.gz
Algorithm Hash digest
SHA256 d7781a210a42a5deaa98677d96c1a1b1da3a3dfd72eb271f042cb25c3d1e9471
MD5 abd7f6af177cd74b80b71c51b8639c0e
BLAKE2b-256 0ef6ff9692a2170c0364ad098e7a69abbe556717bdafcbd7c43e1e9eccb17ea7

See more details on using hashes here.

File details

Details for the file dpac_datetimepicker-3.1.1-py3.7.egg.

File metadata

  • Download URL: dpac_datetimepicker-3.1.1-py3.7.egg
  • Upload date:
  • Size: 120.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/3.6.5

File hashes

Hashes for dpac_datetimepicker-3.1.1-py3.7.egg
Algorithm Hash digest
SHA256 0df7336ecce1c892ba6ff90beb721b5f96587f1e0e992bd5fcbd13186c262d32
MD5 c6f434fb5889e8ba9067c30130e65f1c
BLAKE2b-256 54f56b0505778d901dbdb09bb7b4f52d044f32cb842f64ee9fd8e5ced1b3255d

See more details on using hashes here.

File details

Details for the file dpac_datetimepicker-3.1.1-py3.6.egg.

File metadata

  • Download URL: dpac_datetimepicker-3.1.1-py3.6.egg
  • Upload date:
  • Size: 120.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/3.6.5

File hashes

Hashes for dpac_datetimepicker-3.1.1-py3.6.egg
Algorithm Hash digest
SHA256 33449a608f94c7a75bf257b8e5393777f8092f56538ae78cf8f14be135cb2ff3
MD5 d42503fafe47698e0f3a3e059436d14f
BLAKE2b-256 ae31ed546d0147cc0a1685d335ebfc969b27b0d77e83c14f7528ed8a80ab4b93

See more details on using hashes here.

File details

Details for the file dpac_datetimepicker-3.1.1-py2.7.egg.

File metadata

  • Download URL: dpac_datetimepicker-3.1.1-py2.7.egg
  • Upload date:
  • Size: 120.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/3.6.5

File hashes

Hashes for dpac_datetimepicker-3.1.1-py2.7.egg
Algorithm Hash digest
SHA256 205093aa2d5b8d010f76df56556aa5104fe81e3d35be5c58b009935044825c84
MD5 ecc6dc44e187a1da824f3daa8e39c8e1
BLAKE2b-256 550ebe3e5f82f9f9abb83f140abd20b668d898648a467a553951318343861b82

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