Code

Ticket #3991: choices.diff

File choices.diff, 837 bytes (added by Baptiste <baptiste.goupil@…>, 7 years ago)
Line 
1Index: contrib/admin/options.py
2===================================================================
3--- contrib/admin/options.py    (révision 4970)
4+++ contrib/admin/options.py    (copie de travail)
5@@ -237,10 +237,13 @@
6             else:
7                 # Wrap the widget's render() method with a method that adds
8                 # extra HTML to the end of the rendered output.
9                 formfield = db_field.formfield(**kwargs)
10                 formfield.widget.render = widgets.RelatedFieldWidgetWrapper(formfield.widget.render, db_field.rel)
11                 return formfield
12 
13+        if db_field._choices:
14+            kwargs['widget'] = forms.widgets.Select(choices=db_field._choices)
15+           
16         # For any other type of field, just call its formfield() method.
17         return db_field.formfield(**kwargs)