Bootstrap3 compatible datetimepicker for Django 2.x projects.
Project description
This project was originally a fork of https://github.com/tutorcruncher/django-bootstrap3-datetimepicker : The js/css files are now included again into the project
- This package uses Bootstrap v3 datetimepicker widget version 2 provided by the following project:
- The correct formatting options for dates can be found here:
It works only with Bootstrap3.
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"}))
reminder = forms.DateTimeField(
required=False,
widget=DateTimePicker(options={"format": "YYYY-MM-DD HH:mm"}))
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 }}
Requirements
Python >= 3.4
Django >= 2.0
Bootstrap == 3.X
Moment >= 2.10.6
bootstrap-datetimepicker >= 4.15.35
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
Built Distribution
Hashes for django2-bootstrap3-datetimepicker-3.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c50eae69f46a618edc2be02b15221d17f5488c72a60f33aae8278ab17dc58ed3 |
|
MD5 | bbd8b4d7bfad02f90fe1cbcfb50df2c8 |
|
BLAKE2b-256 | 7f90614038024d36b5c56be7cd83a2e816ae5dc669fdd29cc394df51693dd851 |
Hashes for django2_bootstrap3_datetimepicker-3.0.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eadbedd76e92498dc7a2ebf81bce3ab525d60483d2b15a1a3f57c7029fc3cc02 |
|
MD5 | d74f29e5f50445fb06b9f35b200571af |
|
BLAKE2b-256 | 245f51d69a1415b9778e25fd7fa1f2fe86deb9db63ebd711b34cb1f402dd1b74 |