Changes between Version 6 and Version 7 of AJAXWidgetComboBox
- Timestamp:
- Aug 30, 2006, 11:17:20 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AJAXWidgetComboBox
v6 v7 1 = An AJAX !Select Widget for Django =1 = An AJAX Select Widget for Django = 2 2 3 This widget was written to replace the standard {{{<select>}}} form element Django uses for releated objects in forms. The widget is an extended version of the [http://dojotoolkit.org Dojo] !Select widget. I use this mostly in places where the number of objects in the related objects table exceeds 20 or more. The widget is extracted from a project where some tables have more than 30,000 objects and using a {{{<select>}}} dropdown simply did not scale.3 This widget was written to replace the standard {{{<select>}}} form element Django uses for releated objects in forms. The widget is an extended version of the [http://dojotoolkit.org Dojo] Select widget. I use this mostly in places where the number of objects in the related objects table exceeds 20 or more. The widget is extracted from a project where some tables have more than 30,000 objects and using a {{{<select>}}} dropdown simply did not scale. 4 4 5 5 This widget supports live lookup of related fields based on a single field in that model and autocompletion. … … 38 38 views.py 39 39 urls.py 40 templatetags/ 41 formtags.py 40 42 templates/ 41 43 myapp/ 42 44 mymodel_form.html 45 widget/ 46 fieldrow.html 47 selectrow.html 43 48 media/ 44 49 js/ … … 50 55 == Example Use == 51 56 52 In this example we will create a form that uses the !Select widget to for the Article's reporter field in below.57 In this example we will create a form that uses the Select widget to for the Article's reporter field in below. 53 58 54 59 === Model === … … 103 108 === Template === 104 109 105 Normally you would have just put {{{{{ form.reporter }}}}} somewhere in your {{{article_form.html}}} template to get a drop down menu with a list of the Reporters. To use the new widget in your form you'll need to add the following to your template:110 Normally you would have just put {{{{{ form.reporter }}}}} somewhere in your {{{article_form.html}}} template to get a drop down menu with a list of the Reporters. To use the new widget in your form you'll need to add the following javascript and templatetags to your template: 106 111 107 112 {{{ … … 124 129 Two templatetags are included for your convenience. The first, {% fieldrow ... %} splits out a form element similar in style to the 125 130 Django Admin with the field's help_text displayed. 126 The second, {% selectrow ... %}, splits out all the markup and javascript necessary for the AJAX sele t widget.131 The second, {% selectrow ... %}, splits out all the markup and javascript necessary for the AJAX select widget. 127 132 128 133 Replace the usual {{ form.reporter }} element in the template with this: