1- django-bootstrap3-datetimepicker
2- ================================
1+ # django-bootstrap3-datetimepicker
32
4- This package uses Bootstrap v3 datetimepicker widget version 2 provided by the following project:
5- https://github.com/Eonasdan/bootstrap-datetimepicker
3+ This package uses [ Bootstrap v3 datetimepicker widget version 4] ( https://github.com/Eonasdan/bootstrap-datetimepicker ) .
64
7- The correct formatting options for dates can be found here:
8- http://momentjs.com/docs/
5+ This project is a fork of https://github.com/nkunihiko/django-bootstrap3-datetimepicker with the following changes:
6+ * bug/warning fixes
7+ * remove support for python 2.6 and associated clean up
8+ * js/css files are no longer included in the project, managing them is up to the user
9+ * the widget no longer has js/css assert so you can load them as you wish, this is important as loading
10+ bootstrap-datepicker.js multiple times can cause unexpected behavior.
911
10- It works only with Bootstrap3. If you are using Bootstrap2 in your Django project,
11- visit https://github.com/zokis/django-bootstrap-datetimepicker
12-
13-
14- Install
15- -------------------------------
12+ Install
1613
1714* Run ` pip install django-bootstrap3-datetimepicker `
1815* Add ` 'bootstrap3_datetime' ` to your ` INSTALLED_APPS `
@@ -22,19 +19,22 @@ Example
2219--------------------------------
2320
2421###### forms.py
25- from bootstrap3_datetime.widgets import DateTimePicker
26- from django import forms
27-
28- class ToDoForm(forms.Form):
29- todo = forms.CharField(
30- widget=forms.TextInput(attrs={"class": "form-control"}))
31- date = forms.DateField(
32- widget=DateTimePicker(options={"format": "YYYY-MM-DD",
33- "pickTime": False}))
34- reminder = forms.DateTimeField(
35- required=False,
36- widget=DateTimePicker(options={"format": "YYYY-MM-DD HH:mm",
37- "pickSeconds": False}))
22+
23+ ``` python
24+ from bootstrap3_datetime.widgets import DateTimePicker
25+ from django import forms
26+
27+ class ToDoForm (forms .Form ):
28+ todo = forms.CharField(
29+ widget = forms.TextInput(attrs = {" class" : " form-control" }))
30+ date = forms.DateField(
31+ widget = DateTimePicker(options = {" format" : " YYYY-MM-DD" ,
32+ " pickTime" : False }))
33+ reminder = forms.DateTimeField(
34+ required = False ,
35+ widget = DateTimePicker(options = {" format" : " YYYY-MM-DD HH:mm" ,
36+ " pickSeconds" : False }))
37+ ```
3838
3939The ` options ` will be passed to the JavaScript datetimepicker instance.
4040Available ` options ` are explained in the following documents:
@@ -45,72 +45,55 @@ You don't need to set the `language` option,
4545because it will be set the current language of the thread automatically.
4646
4747###### template.html
48- <!DOCTYPE html>
49- <html>
50- <head>
51- <link rel="stylesheet"
52- href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.css">
53- <link rel="stylesheet"
54- href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.css">
55- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.js">
56- </script>
57- <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.js">
58- </script>
59- {{ form.media }}
60- </head>
61- <body>
62- <form method="post" role="form">
63- {% for field in form.visible_fields %}
64- <div id="div_{{ field.html_name }}"
65- class="form-group{% if field.errors %} has-error{% endif %}">
66- {{ field.label_tag }}
67- {{ field }}
68- <div class="text-muted pull-right">
69- <small>{{ field.help_text }}</small>
70- </div>
71- <div class="help-block">
72- {{ field.errors }}
73- </div>
74- </div>
75- {% endfor %}
76- {% for hidden in form.hidden_fields %}
77- {{ hidden }}
78- {% endfor %}
79- {% csrf_token %}
80- <div class="form-group">
81- <input type="submit" value="Submit" class="btn btn-primary" />
82- </div>
83- </form>
84- </body>
85- </html>
86-
87- Bootstrap3 and jQuery have to be included along with ` {{ form.media }} `
88-
89-
90- Release Notes
91- -------------------------------
9248
93- ###### v2.3
94-
95- * Updated bootstrap-datetimepicker.js to version 3.0
96-
97-
98- ###### v2.2.3
99-
100- * Updated bootstrap-datetimepicker.js to version 2.1.30
101-
102-
103- ###### v2.0.0
104-
105- * Includes bootstrap-datetimepicker.js version 2.1.11 with moment.js
106- * The format strings have changed due to using moment.js
49+ ``` html+jinja
50+ <!DOCTYPE html>
51+ <html>
52+ <head>
53+ <link rel="stylesheet"
54+ href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.css">
55+ <link rel="stylesheet"
56+ href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.css">
57+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.js">
58+ </script>
59+ <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.js">
60+ </script>
61+ {{ form.media }}
62+ </head>
63+ <body>
64+ <form method="post" role="form">
65+ {% for field in form.visible_fields %}
66+ <div id="div_{{ field.html_name }}"
67+ class="form-group{% if field.errors %} has-error{% endif %}">
68+ {{ field.label_tag }}
69+ {{ field }}
70+ <div class="text-muted pull-right">
71+ <small>{{ field.help_text }}</small>
72+ </div>
73+ <div class="help-block">
74+ {{ field.errors }}
75+ </div>
76+ </div>
77+ {% endfor %}
78+ {% for hidden in form.hidden_fields %}
79+ {{ hidden }}
80+ {% endfor %}
81+ {% csrf_token %}
82+ <div class="form-group">
83+ <input type="submit" value="Submit" class="btn btn-primary" />
84+ </div>
85+ </form>
86+ </body>
87+ </html>
88+ ```
10789
90+ Bootstrap3 and jQuery have to be included along with ` {{ form.media }} `
10891
10992Requirements
11093-------------------------------
11194
112- * Python >= 2.4
113- * Django >= 1.3
95+ * Python >= 2.7
96+ * Django >= 1.8
11497* Bootstrap >= 3.0
11598
11699
0 commit comments