Skip to content

Commit 8f6f6c2

Browse files
committed
Added readthedocs documentation
1 parent 362ec63 commit 8f6f6c2

File tree

13 files changed

+1064
-0
lines changed

13 files changed

+1064
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
.vscode
33
node_modules
44
db.sqlite3
5+
docs/_build
6+
docs/pydoc.io/autoapi
57

68
# Byte-compiled / optimized / DLL files
79
__pycache__/

docs/Contributing.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Contributing
2+
------------
3+
4+
- `CONTRIBUTING.md <https://github.com/monim67/django-bootstrap-datepicker-plus/blob/master/.github/CONTRIBUTING.md>`__.
5+
- `CODE_OF_CONDUCT.md <https://github.com/monim67/django-bootstrap-datepicker-plus/blob/master/.github/CODE_OF_CONDUCT.md>`__.
6+
7+
License
8+
-------
9+
10+
This project is licensed under Apache License 2.0 - see the `LICENSE <https://github.com/monim67/django-bootstrap-datepicker-plus/blob/master/LICENSE>`__ file for details.
11+
12+
Acknowledgments
13+
---------------
14+
15+
This project implements `Eonasdan/bootstrap-datetimepicker <https://github.com/Eonasdan/bootstrap-datetimepicker>`__ to display date-pickers.
16+
The project was initially forked from `pbucher/django-bootstrap-datepicker <https://github.com/pbucher/django-bootstrap-datepicker>`__.
17+
18+

docs/Getting_Started.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Getting Started
2+
---------------
3+
4+
5+
Prerequisites
6+
^^^^^^^^^^^^^
7+
- Python >= 3.3
8+
- Django >= 1.8
9+
- Bootstrap >= 3
10+
- jquery >= 1.7.1
11+
12+
13+
Installing
14+
^^^^^^^^^^
15+
Install the widget via pip
16+
17+
::
18+
19+
pip install django-bootstrap-datepicker-plus
20+
21+
Add ``bootstrap_datepicker_plus`` to the list of ``INSTALLED_APPS`` in your ``settings.py`` file.
22+
23+
.. code:: python
24+
25+
INSTALLED_APPS = [
26+
# Add the following
27+
'bootstrap_datepicker_plus',
28+
]
29+
30+
``jQuery`` is needed for ``datepicker`` to render, make sure you have jQuery in your template,
31+
or you can use ``jQuery`` included with ``Bootstrap`` by setting ``include_jquery`` option to ``True``
32+
in your ``settings.py`` file.
33+
If you don't have ``BOOTSTRAP3``/``BOOTSTRAP4`` settings block you have to create one.
34+
35+
.. code:: python
36+
37+
# Use BOOTSTRAP3 if you are using Bootstrap 3
38+
BOOTSTRAP4 = {
39+
'include_jquery': True,
40+
}
41+
42+
Make sure you have bootstrap tags in your template along with ``forms.media`` tag,
43+
it adds all JS and CSS resources needed to render the date-picker.
44+
45+
.. code:: html
46+
47+
{% load bootstrap4 %} {# import bootstrap4/bootstrap3 #}
48+
{% bootstrap_css %} {# Embed Bootstrap CSS #}
49+
{% bootstrap_javascript jquery='full' %} {# Embed Bootstrap JS+jQuery #}
50+
{{ form.media }} {# Adds date-picker required JS and CSS #}
51+
52+
The ``form.media`` tag is only for Generic Views. If you are generating the view yourself
53+
and passing the form to ``render`` function, you have to use ``<your-form-variable>.media``.
54+
For Example, in case of the following example you have to use ``{{ my_form.media }}``
55+
instead of ``{{ form.media }}``.
56+
57+
.. code:: python
58+
59+
# File: views.py
60+
from django.shortcuts import render
61+
from .forms import UserForm
62+
63+
def create_user(request):
64+
user_form = UserForm()
65+
return render(request, 'my_template.html', {'my_form': user_form})

docs/Makefile

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
10+
# User-friendly check for sphinx-build
11+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
12+
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
13+
endif
14+
15+
# Internal variables.
16+
PAPEROPT_a4 = -D latex_paper_size=a4
17+
PAPEROPT_letter = -D latex_paper_size=letter
18+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19+
# the i18n builder cannot share the environment and doctrees with the others
20+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
21+
22+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
23+
24+
help:
25+
@echo "Please use \`make <target>' where <target> is one of"
26+
@echo " html to make standalone HTML files"
27+
@echo " dirhtml to make HTML files named index.html in directories"
28+
@echo " singlehtml to make a single large HTML file"
29+
@echo " pickle to make pickle files"
30+
@echo " json to make JSON files"
31+
@echo " htmlhelp to make HTML files and a HTML help project"
32+
@echo " qthelp to make HTML files and a qthelp project"
33+
@echo " devhelp to make HTML files and a Devhelp project"
34+
@echo " epub to make an epub"
35+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
36+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
37+
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
38+
@echo " text to make text files"
39+
@echo " man to make manual pages"
40+
@echo " texinfo to make Texinfo files"
41+
@echo " info to make Texinfo files and run them through makeinfo"
42+
@echo " gettext to make PO message catalogs"
43+
@echo " changes to make an overview of all changed/added/deprecated items"
44+
@echo " xml to make Docutils-native XML files"
45+
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
46+
@echo " linkcheck to check all external links for integrity"
47+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
48+
49+
clean:
50+
rm -rf $(BUILDDIR)/*
51+
52+
html:
53+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
54+
@echo
55+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
56+
57+
dirhtml:
58+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
59+
@echo
60+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
61+
62+
singlehtml:
63+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
64+
@echo
65+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
66+
67+
pickle:
68+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
69+
@echo
70+
@echo "Build finished; now you can process the pickle files."
71+
72+
json:
73+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
74+
@echo
75+
@echo "Build finished; now you can process the JSON files."
76+
77+
htmlhelp:
78+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
79+
@echo
80+
@echo "Build finished; now you can run HTML Help Workshop with the" \
81+
".hhp project file in $(BUILDDIR)/htmlhelp."
82+
83+
qthelp:
84+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
85+
@echo
86+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
87+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
88+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhcp"
89+
@echo "To view the help file:"
90+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ReadtheDocsTemplate.qhc"
91+
92+
devhelp:
93+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
94+
@echo
95+
@echo "Build finished."
96+
@echo "To view the help file:"
97+
@echo "# mkdir -p $$HOME/.local/share/devhelp/ReadtheDocsTemplate"
98+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ReadtheDocsTemplate"
99+
@echo "# devhelp"
100+
101+
epub:
102+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
103+
@echo
104+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
105+
106+
latex:
107+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
108+
@echo
109+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
110+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
111+
"(use \`make latexpdf' here to do that automatically)."
112+
113+
latexpdf:
114+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
115+
@echo "Running LaTeX files through pdflatex..."
116+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
117+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
118+
119+
latexpdfja:
120+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
121+
@echo "Running LaTeX files through platex and dvipdfmx..."
122+
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
123+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
124+
125+
text:
126+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
127+
@echo
128+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
129+
130+
man:
131+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
132+
@echo
133+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
134+
135+
texinfo:
136+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
137+
@echo
138+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
139+
@echo "Run \`make' in that directory to run these through makeinfo" \
140+
"(use \`make info' here to do that automatically)."
141+
142+
info:
143+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
144+
@echo "Running Texinfo files through makeinfo..."
145+
make -C $(BUILDDIR)/texinfo info
146+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
147+
148+
gettext:
149+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
150+
@echo
151+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
152+
153+
changes:
154+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
155+
@echo
156+
@echo "The overview file is in $(BUILDDIR)/changes."
157+
158+
linkcheck:
159+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
160+
@echo
161+
@echo "Link check complete; look for any errors in the above output " \
162+
"or in $(BUILDDIR)/linkcheck/output.txt."
163+
164+
doctest:
165+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
166+
@echo "Testing of doctests in the sources finished, look at the " \
167+
"results in $(BUILDDIR)/doctest/output.txt."
168+
169+
xml:
170+
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
171+
@echo
172+
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
173+
174+
pseudoxml:
175+
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
176+
@echo
177+
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

docs/Usage.rst

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
Usage
2+
-----
3+
4+
5+
Custom Form usage
6+
^^^^^^^^^^^^^^^^^
7+
8+
.. code:: python
9+
10+
# File: forms.py
11+
from bootstrap_datepicker_plus import DatePickerInput
12+
from django import forms
13+
14+
class ToDoForm(forms.Form):
15+
todo = forms.CharField(
16+
widget=forms.TextInput(attrs={"class": "form-control"})
17+
)
18+
date = forms.DateField(
19+
widget=DatePickerInput(format='%m/%d/%Y')
20+
)
21+
22+
23+
Model Form usage
24+
^^^^^^^^^^^^^^^^
25+
26+
.. code:: python
27+
28+
# File: forms.py
29+
from bootstrap_datepicker_plus import DatePickerInput
30+
from django import forms
31+
32+
class EventForm(forms.ModelForm):
33+
class Meta:
34+
model = Event
35+
fields = ['name', 'start_date', 'end_date']
36+
widgets = {
37+
'start_date': DatePickerInput(), # default date-format %m/%d/%Y will be used
38+
'end_date': DatePickerInput(format='%Y-%m-%d'), # specify date-frmat
39+
}
40+
41+
42+
Types of DatePickers
43+
^^^^^^^^^^^^^^^^^^^^
44+
45+
The widget contains all types of date-picker you may ever need.
46+
47+
.. code:: python
48+
49+
# File: forms.py
50+
from bootstrap_datepicker_plus import DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput
51+
from django import forms
52+
53+
class EventForm(forms.ModelForm):
54+
class Meta:
55+
model = Event
56+
fields = ['start_date', 'start_time', 'start_datetime', 'start_month', 'start_year']
57+
widgets = {
58+
'start_date': DatePickerInput(),
59+
'start_time': TimePickerInput(),
60+
'start_datetime': DateTimePickerInput(),
61+
'start_month': MonthPickerInput(),
62+
'start_year': YearPickerInput(),
63+
}
64+
65+
66+
Implement date-range-picker
67+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+
69+
DatePickers can be linked to select a date-range or time-range.
70+
71+
.. code:: python
72+
73+
# File: forms.py
74+
from bootstrap_datepicker_plus import DatePickerInput, TimePickerInput
75+
from django import forms
76+
77+
class EventForm(forms.ModelForm):
78+
class Meta:
79+
model = Event
80+
fields = ['name', 'start_date', 'end_date', 'start_time', 'end_time']
81+
widgets = {
82+
'start_date':DatePickerInput().start_of('event days'),
83+
'end_date':DatePickerInput().end_of('event days'),
84+
'start_time':TimePickerInput().start_of('party time'),
85+
'end_time':TimePickerInput().end_of('party time'),
86+
}
87+
88+
89+
Customize the Options
90+
^^^^^^^^^^^^^^^^^^^^^
91+
92+
The DatePicker can be customised by passing options to it.
93+
The ``options`` will be passed to the JavaScript datepicker instance, and are documented and demonstrated in
94+
`Bootstrap Datepicker Options Reference <http://eonasdan.github.io/bootstrap-datetimepicker/Options/>`__.
95+
96+
.. code:: python
97+
98+
# File: forms.py
99+
from bootstrap_datepicker_plus import DatePickerInput
100+
from django import forms
101+
102+
class EventForm(forms.ModelForm):
103+
class Meta:
104+
model = Event
105+
fields = ['name', 'start_date', 'end_date']
106+
widgets = {
107+
'start_date': DatePickerInput(format='%m/%d%Y'), # python date-time format
108+
'end_date': DatePickerInput(
109+
options={
110+
"format": "MM/DD/YYYY", # moment date-time format
111+
"showClose": True,
112+
"showClear": True,
113+
"showTodayButton": True,
114+
}
115+
),
116+
}
117+
118+
**Note:** You can specify the date-time format by passing a
119+
`python date-time format <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`__
120+
as format parameter (see start_date in the example), or by passing a
121+
`moment date-time format <http://momentjs.com/docs/#/displaying/format/>`__
122+
as an option (see end_date in the example).
123+
If both are specified then the moment format in options will take precedence.
124+
125+

0 commit comments

Comments
 (0)