mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
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
This commit is contained in:
parent
fb3994bdfc
commit
dac6f2d37b
@ -145,11 +145,6 @@ class BaseModelAdmin(object):
|
|||||||
|
|
||||||
If kwargs are given, they're passed to the form Field's constructor.
|
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.
|
# For DateTimeFields, use a special field and widget.
|
||||||
if isinstance(db_field, models.DateTimeField):
|
if isinstance(db_field, models.DateTimeField):
|
||||||
kwargs['form_class'] = forms.SplitDateTimeField
|
kwargs['form_class'] = forms.SplitDateTimeField
|
||||||
@ -176,9 +171,12 @@ class BaseModelAdmin(object):
|
|||||||
if isinstance(db_field, models.ForeignKey) and db_field.name in self.raw_id_fields:
|
if isinstance(db_field, models.ForeignKey) and db_field.name in self.raw_id_fields:
|
||||||
kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel)
|
kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel)
|
||||||
else:
|
else:
|
||||||
if isinstance(db_field, models.ManyToManyField) and db_field.name in self.raw_id_fields:
|
if isinstance(db_field, models.ManyToManyField):
|
||||||
|
if db_field.name in self.raw_id_fields:
|
||||||
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel)
|
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel)
|
||||||
kwargs['help_text'] = ''
|
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
|
# Wrap the widget's render() method with a method that adds
|
||||||
# extra HTML to the end of the rendered output.
|
# extra HTML to the end of the rendered output.
|
||||||
formfield = db_field.formfield(**kwargs)
|
formfield = db_field.formfield(**kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user