Skip to content

Commit c2331b2

Browse files
intioceancodingjoe
authored andcommitted
Add some quickstart docs (applegrew#467)
Add some quickstart docs to make it easy for someone to pick up the library and get going straight away.
1 parent 5d98048 commit c2331b2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/get_started.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,34 @@ Installation
2323

2424
url(r'^select2/', include('django_select2.urls')),
2525

26+
Quick Start
27+
-----------
28+
29+
Here is a quick example to get you started:
30+
31+
0. Follow the installation instructions above.
32+
33+
1. Add a select2 widget to the form. For example if you wanted Select2 with multi-select you would use
34+
``Select2MultipleWidget``
35+
Replacing::
36+
37+
class MyForm(forms.Form):
38+
things = ModelMultipleChoiceField(queryset=Thing.objects.all())
39+
40+
with::
41+
42+
class MyForm(forms.Form):
43+
things = ModelMultipleChoiceField(queryset=Thing.objects.all(), widget=Select2MultipleWidget)
44+
45+
2. Add the CSS to the ``head`` of your Django template::
46+
47+
{{ form.media.css }}
48+
49+
3. Add the JavaScript to the end of the ``body`` of your Django template::
50+
51+
{{ form.media.js }}
52+
53+
4. Done - enjoy the wonders of Select2!
2654

2755
External Dependencies
2856
---------------------

0 commit comments

Comments
 (0)