Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

newforms-admin: Fixed #6202 -- FilteredSelectMultiple is now wrapped …

…with RelatedFieldWidgetWrapper to display the add button.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7195 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit dac6f2d37b3b1447cd1aced0567be3b361551dfb 1 parent fb3994b
@brosner brosner authored
Showing with 6 additions and 8 deletions.
  1. +6 −8 django/contrib/admin/options.py
View
14 django/contrib/admin/options.py
@@ -145,11 +145,6 @@ def formfield_for_dbfield(self, db_field, **kwargs):
If kwargs are given, they're passed to the form Field's constructor.
"""
- # For ManyToManyFields with a filter interface, use a special widget.
- if isinstance(db_field, models.ManyToManyField) and db_field.name in (self.filter_vertical + self.filter_horizontal):
- kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))
- return db_field.formfield(**kwargs)
-
# For DateTimeFields, use a special field and widget.
if isinstance(db_field, models.DateTimeField):
kwargs['form_class'] = forms.SplitDateTimeField
@@ -176,9 +171,12 @@ def formfield_for_dbfield(self, db_field, **kwargs):
if isinstance(db_field, models.ForeignKey) and db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel)
else:
- if isinstance(db_field, models.ManyToManyField) and db_field.name in self.raw_id_fields:
- kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel)
- kwargs['help_text'] = ''
+ if isinstance(db_field, models.ManyToManyField):
+ if db_field.name in self.raw_id_fields:
+ kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel)
+ kwargs['help_text'] = ''
+ elif db_field.name in (self.filter_vertical + self.filter_horizontal):
+ kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))
# Wrap the widget's render() method with a method that adds
# extra HTML to the end of the rendered output.
formfield = db_field.formfield(**kwargs)
Please sign in to comment.
Something went wrong with that request. Please try again.