Skip to content

Commit 67b6b86

Browse files
committed
README+docs update [ci skip]
1 parent b318279 commit 67b6b86

File tree

3 files changed

+76
-75
lines changed

3 files changed

+76
-75
lines changed

README.rst

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Prerequisites
3939

4040
Installing
4141
^^^^^^^^^^
42-
Install the widget via pip
42+
Install the PyPI package via pip
4343

4444
::
4545

@@ -55,51 +55,46 @@ Add ``bootstrap_datepicker_plus`` to the list of ``INSTALLED_APPS`` in your ``se
5555
]
5656
5757
This installation instruction assumes you have ``jQuery`` and Bootstrap JS/CSS files present in your template
58-
and you are using ``form.media`` in your django template. If not you should checkout our
59-
`configuration instructions <https://monim67.github.io/django-bootstrap-datepicker-plus/configure/>`__
60-
which covers almost everything you need to get the widget running.
58+
and you are using ``form.media`` in your django template. If not you have to configure your template.
59+
60+
61+
Next
62+
^^^^^^^^^^
63+
- `Template configuration <https://monim67.github.io/django-bootstrap-datepicker-plus/configure/>`__
64+
- `Documentation on ReadTheDocs <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/>`__
65+
- `Quick Walkthrough Tutorial <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Walkthrough.html>`__
66+
- `I am having errors <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Troubleshooting.html>`__
6167

6268

6369

6470
Usage
6571
-----
6672

6773

68-
Custom Form usage
69-
^^^^^^^^^^^^^^^^^
74+
Usage in Generic View
75+
^^^^^^^^^^^^^^^^^^^^^^
7076

7177
.. code:: python
7278
73-
# File: forms.py
74-
from bootstrap_datepicker_plus import DatePickerInput
75-
from django import forms
79+
# File: views.py
80+
from bootstrap_datepicker_plus import DateTimePickerInput
81+
from django.views import generic
82+
from .models import Question
7683
77-
class ToDoForm(forms.Form):
78-
todo = forms.CharField(
79-
widget=forms.TextInput(attrs={"class": "form-control"})
80-
)
81-
date = forms.DateField(
82-
widget=DatePickerInput(format='%m/%d/%Y')
83-
)
84+
class CreateView(generic.edit.CreateView):
85+
model = Question
86+
fields = ['question_text', 'pub_date']
87+
def get_form(self):
88+
form = super().get_form()
89+
form.fields['pub_date'].widget = DateTimePickerInput()
90+
return form
8491
8592
86-
Model Form usage
87-
^^^^^^^^^^^^^^^^
88-
89-
.. code:: python
90-
91-
# File: forms.py
92-
from bootstrap_datepicker_plus import DatePickerInput
93-
from django import forms
93+
Advanced Usage
94+
^^^^^^^^^^^^^^^^^
9495

95-
class EventForm(forms.ModelForm):
96-
class Meta:
97-
model = Event
98-
fields = ['name', 'start_date', 'end_date']
99-
widgets = {
100-
'start_date': DatePickerInput(), # default date-format %m/%d/%Y will be used
101-
'end_date': DatePickerInput(format='%Y-%m-%d'), # specify date-frmat
102-
}
96+
- `Usage in Custom Form <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Usage.html#custom-form-usage>`__
97+
- `Usage in Model Form <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Usage.html#model-form-usage>`__
10398

10499

105100
Types of DatePickers
@@ -149,41 +144,11 @@ DatePickers can be linked to select a date-range or time-range.
149144
}
150145
151146
152-
Customize the Options
153-
^^^^^^^^^^^^^^^^^^^^^
154-
155-
The DatePicker can be customised by passing options to it.
156-
The ``options`` will be passed to the JavaScript datepicker instance, and are documented and demonstrated in
157-
`Bootstrap Datepicker Options Reference <http://eonasdan.github.io/bootstrap-datetimepicker/Options/>`__.
158-
159-
.. code:: python
160-
161-
# File: forms.py
162-
from bootstrap_datepicker_plus import DatePickerInput
163-
from django import forms
164-
165-
class EventForm(forms.ModelForm):
166-
class Meta:
167-
model = Event
168-
fields = ['name', 'start_date', 'end_date']
169-
widgets = {
170-
'start_date': DatePickerInput(format='%m/%d%Y'), # python date-time format
171-
'end_date': DatePickerInput(
172-
options={
173-
"format": "MM/DD/YYYY", # moment date-time format
174-
"showClose": True,
175-
"showClear": True,
176-
"showTodayButton": True,
177-
}
178-
),
179-
}
180-
181-
**Note:** You can specify the date-time format by passing a
182-
`python date-time format <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`__
183-
as format parameter (see start_date in the example), or by passing a
184-
`moment date-time format <http://momentjs.com/docs/#/displaying/format/>`__
185-
as an option (see end_date in the example).
186-
If both are specified then the moment format in options will take precedence.
147+
Customization
148+
^^^^^^^^^^^^^^
149+
- `Datepicker Options <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Usage.html#customize-datepicker-options>`__
150+
- `Input field HTML template <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Template_Customizing.html>`__
151+
- `Language <https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Usage.html#customize-the-language>`__
187152

188153

189154
Contributing

docs/Usage.rst

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Custom Form usage
2828
2929
# File: forms.py
3030
from bootstrap_datepicker_plus import DatePickerInput
31+
from .models import Event
3132
from django import forms
3233
3334
class ToDoForm(forms.Form):
@@ -68,6 +69,7 @@ The widget contains all types of date-picker you may ever need.
6869
6970
# File: forms.py
7071
from bootstrap_datepicker_plus import DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput
72+
from .models import Event
7173
from django import forms
7274
7375
class EventForm(forms.ModelForm):
@@ -92,6 +94,7 @@ DatePickers can be linked to select a date-range or time-range.
9294
9395
# File: forms.py
9496
from bootstrap_datepicker_plus import DatePickerInput, TimePickerInput
97+
from .models import Event
9598
from django import forms
9699
97100
class EventForm(forms.ModelForm):
@@ -106,17 +109,18 @@ DatePickers can be linked to select a date-range or time-range.
106109
}
107110
108111
109-
Customize the Options
110-
^^^^^^^^^^^^^^^^^^^^^
112+
Customize Datepicker Options
113+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111114

112-
The DatePicker can be customised by passing options to it.
115+
The DatePicker can be customized by passing options to it.
113116
The ``options`` will be passed to the JavaScript datepicker instance, and are documented and demonstrated in
114117
`Bootstrap Datepicker Options Reference <http://eonasdan.github.io/bootstrap-datetimepicker/Options/>`__.
115118

116119
.. code:: python
117120
118121
# File: forms.py
119122
from bootstrap_datepicker_plus import DatePickerInput
123+
from .models import Event
120124
from django import forms
121125
122126
class EventForm(forms.ModelForm):
@@ -143,3 +147,30 @@ as an option (see end_date in the example).
143147
If both are specified then the moment format in options will take precedence.
144148

145149

150+
Customize the Language
151+
^^^^^^^^^^^^^^^^^^^^^^^
152+
153+
The DatePicker language can be customized by passing a ``locale`` option to datepicker input.
154+
See `moment.js locales <https://github.com/moment/moment/tree/develop/locale>`__ for valid locales.
155+
156+
.. code:: python
157+
158+
# File: forms.py
159+
from bootstrap_datepicker_plus import DatePickerInput
160+
from .models import Event
161+
from django import forms
162+
163+
class EventForm(forms.ModelForm):
164+
class Meta:
165+
model = Event
166+
fields = ['name', 'pub_date']
167+
widgets = {
168+
'pub_date': DatePickerInput(
169+
options={
170+
"format": "MM/DD/YYYY",
171+
"locale": "bn",
172+
}
173+
),
174+
}
175+
176+

docs/Walkthrough.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ Quick Walkthrough Tutorial
22
--------------------------
33

44
This tutorial will take off where django official tutorial `Writing your first Django app, part 4 <django_tutorial_04_>`_
5-
left off. The Question model has a datetime field. We are going to create a page to add new poll questions
6-
and a page to edit them.
5+
left off. If you don't have the project you can clone the following repository and checkout to completion of tutorial 04.
76

7+
::
88

9+
git clone https://github.com/monim67/django-polls
10+
cd django-polls
11+
git checkout d2.1t4
912

10-
.. tip:: We are going to use Bootstrap 4 here, if you are using Bootstrap 3 just replace the 4's with 3's in the
11-
codes and instructions below.
1213

13-
Open up your console and install the following packages:
14+
The Question model has a datetime field. We are going to create a page to add new poll questions and a page to edit
15+
them with a date-time-picker calendar on the datetime field.
16+
We are going to use Bootstrap 4 here, if you are using Bootstrap 3 just replace the 4's with 3's in the codes
17+
and instructions below.
18+
Install following packages:
1419

1520
::
1621

0 commit comments

Comments
 (0)