djangosnippets.org: Latest snippets tagged with 'selection'http://djangosnippets.org/tags/selection/2008-09-30T09:55:20.644677-05:00Django JQuery Autocomplete for Model Selection
2008-09-30T09:55:20.644677-05:00elpeniahttp://djangosnippets.org/snippets/1097/<p>This is a general JQuery Autocomplete Form Field for selecting any model instance in your forms.</p>
<p>1 Download jquery.1.2.6 and the jquery autocomplete plugin http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/, place theme somewhere in your media directory (in this case {{ MEDIA__URL}}/js/</p>
<p>2 copy fields.py to anywhere in your python-path (in this case utils.fields)</p>
<p>3 …</p>
Freely redistributableautocompleter with database query
2007-07-05T11:37:17.002356-05:00bbollihttp://djangosnippets.org/snippets/303/<p>This is an improvement of snippet 253 in that it supports database queries.</p>
<p>Implementing autocompletion for foreign keys takes a few steps:</p>
<p>1) Put the snippet above into <app>/widgets/autocomplete.py.</p>
<p>2) Create a view of your foreign key model (here: Donator) in <app>/donator/views.py:</p>
<pre><code>from models import Donator
from widgets.autocomplete import autocomplete_response …</code></pre>
Freely redistributableMultipleChoiceCommaField
2007-02-26T11:22:57.600249-06:00rubichttp://djangosnippets.org/snippets/23/<p>MultipleChoiceCommaField - CheckboxSelectMultiple value sequence as a single string, comma-separated.
</p>
<p>Since I frequently want to store multiple-selected choice items as a single field in the model, I found it convenient to write a custom field class. The code uses the comma as a separator, but it could be easily generalized …</p>
Freely redistributable