1. class SelectWithNumberShortcuts(forms.widgets.Select):
  2. def __init__(self, attrs=None, choices=()):
  3. self.choices = [(iid,
  4. u"{shorcut} - {label}".format(**
  5. {'shorcut': i,
  6. 'label': label}))
  7. for i, (iid, label) in enumerate(choices)]
  8. super(SelectWithNumberShortcuts, self).__init__(attrs, choices)

Wanted to implement to have labels with numbers at the start instead of just text for quicker keyboard access.

So, instead of this:

<select name="name" id="id_document">

<option value="1">Label 1</option>

<option value="2">Label 2</option>

<option value="3">Label 3</option>

...

</select>

I would render this:

<select name="name" id="id_document">

<option value="1">1 - Label 1</option>

<option value="2">2- Label 2</option>

<option value="3">3 - Label 3</option>

...

</select>

Any ideas how this should be accomplished or why this doesn't work?