|
7 | 7 | library, hence these components are meant to be used
|
8 | 8 | with choice fields.
|
9 | 9 |
|
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. |
40 | 47 |
|
41 | 48 | Heavy and Model widgets have respectively the word 'Heavy' and 'Model' in
|
42 | 49 | their name. Light widgets are normally named, i.e. there is no 'Light' word
|
|
0 commit comments