Skip to content

Commit 681fac9

Browse files
Note case in which cache is not needed (#233)
Co-authored-by: Johannes Maron <[email protected]>
1 parent 5753384 commit 681fac9

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

django_select2/forms.py

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,43 @@
77
library, hence these components are meant to be used
88
with choice fields.
99
10-
Widgets are generally of two types:
11-
12-
1. **Light** --
13-
They are not meant to be used when there
14-
are too many options, say, in thousands.
15-
This is because all those options would
16-
have to be pre-rendered onto the page
17-
and JavaScript would be used to search
18-
through them. Said that, they are also one
19-
the easiest to use. They are a
20-
drop-in-replacement for Django's default
21-
select widgets.
22-
23-
2(a). **Heavy** --
24-
They are suited for scenarios when the number of options
25-
are large and need complex queries (from maybe different
26-
sources) to get the options.
27-
28-
This dynamic fetching of options undoubtedly requires
29-
Ajax communication with the server. Django-Select2 includes
30-
a helper JS file which is included automatically,
31-
so you need not worry about writing any Ajax related JS code.
32-
Although on the server side you do need to create a view
33-
specifically to respond to the queries.
34-
35-
2(b). **Model** --
36-
Model-widgets are a further specialized versions of Heavies.
37-
These do not require views to serve Ajax requests.
38-
When they are instantiated, they register themselves
39-
with one central view which handles Ajax requests for them.
10+
Widgets are generally of tree types:
11+
Light, Heavy and Model.
12+
13+
Light
14+
~~~~~
15+
16+
They are not meant to be used when there
17+
are too many options, say, in thousands.
18+
This is because all those options would
19+
have to be pre-rendered onto the page
20+
and JavaScript would be used to search
21+
through them. Said that, they are also one
22+
the easiest to use. They are a
23+
drop-in-replacement for Django's default
24+
select widgets.
25+
26+
Heavy
27+
~~~~~
28+
29+
They are suited for scenarios when the number of options
30+
are large and need complex queries (from maybe different
31+
sources) to get the options.
32+
33+
This dynamic fetching of options undoubtedly requires
34+
Ajax communication with the server. Django-Select2 includes
35+
a helper JS file which is included automatically,
36+
so you need not worry about writing any Ajax related JS code.
37+
Although on the server side you do need to create a view
38+
specifically to respond to the queries.
39+
40+
Model
41+
~~~~~
42+
43+
Model-widgets are a further specialized versions of Heavies.
44+
These do not require views to serve Ajax requests.
45+
When they are instantiated, they register themselves
46+
with one central view which handles Ajax requests for them.
4047
4148
Heavy and Model widgets have respectively the word 'Heavy' and 'Model' in
4249
their name. Light widgets are normally named, i.e. there is no 'Light' word

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
extensions = [
3333
"sphinx.ext.autodoc",
34+
"sphinx.ext.autosectionlabel",
3435
"sphinx.ext.napoleon",
3536
"sphinx.ext.inheritance_diagram",
3637
"sphinx.ext.intersphinx",

docs/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ Add ``django_select`` to your URL root configuration:
3232
]
3333
3434
35-
``django-select2`` requires a cache backend which is **persistent**
36-
across all application servers..
35+
The :ref:`Model` -widgets require a **persistent** cache backend across
36+
all application servers. This is because the widget needs to store
37+
meta data to be able to fetch the results based on the user input.
3738

3839
**This means that the** :class:`.DummyCache` **backend will not work!**
3940

0 commit comments

Comments
 (0)