Skip to content

Commit f52340e

Browse files
authored
Document how to use additional formats
The discussion at #15 is very useful. This PR adds the information to the docs.
1 parent 55819bf commit f52340e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/Usage.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,29 @@ as an option (see end_date in the example).
153153
If both are specified then the moment format in options will take precedence.
154154

155155

156+
Customize DatePicker Format
157+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
158+
159+
In order to use arbitraty formats you must specify the pattern to the field's ``input_formats`` and the widget's ``format``.
160+
161+
.. code-block:: python
162+
:emphasize-lines: 11-12
163+
164+
# File: forms.py
165+
from bootstrap_datepicker_plus import DatePickerInput
166+
from .models import Event
167+
from django import forms
168+
169+
class ToDoForm(forms.Form):
170+
todo = forms.CharField(
171+
widget=forms.TextInput(attrs={"class": "form-control"})
172+
)
173+
date = forms.DateField(
174+
input_formats=['%d/%m/%Y'],
175+
widget=DatePickerInput(format='%d/%m/%Y')
176+
)
177+
178+
156179
Customize the Language
157180
^^^^^^^^^^^^^^^^^^^^^^^
158181

0 commit comments

Comments
 (0)