mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
newforms-admin: Fixed a bug in formfield_for_dbfield()
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4417 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cb57d82cde
commit
668671561d
@ -205,8 +205,8 @@ class ModelAdmin(object):
|
|||||||
"""
|
"""
|
||||||
# For filter_interface ManyToManyFields, use a special Widget.
|
# For filter_interface ManyToManyFields, use a special Widget.
|
||||||
if isinstance(db_field, models.ManyToManyField) and db_field.rel.filter_interface:
|
if isinstance(db_field, models.ManyToManyField) and db_field.rel.filter_interface:
|
||||||
widget = widgets.FilteredSelectMultiple(db_field.verbose_name, db_field.rel.filter_interface-1)
|
kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, db_field.rel.filter_interface-1)
|
||||||
return db_field.formfield(widget=widget, **kwargs)
|
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):
|
||||||
@ -215,17 +215,19 @@ class ModelAdmin(object):
|
|||||||
|
|
||||||
# For DateFields, add a custom CSS class.
|
# For DateFields, add a custom CSS class.
|
||||||
if isinstance(db_field, models.DateField):
|
if isinstance(db_field, models.DateField):
|
||||||
return db_field.formfield(widget=forms.TextInput(attrs={'class': 'vDateField', 'size': '10'}))
|
kwargs['widget'] = forms.TextInput(attrs={'class': 'vDateField', 'size': '10'})
|
||||||
|
return db_field.formfield(**kwargs)
|
||||||
|
|
||||||
# For TimeFields, add a custom CSS class.
|
# For TimeFields, add a custom CSS class.
|
||||||
if isinstance(db_field, models.TimeField):
|
if isinstance(db_field, models.TimeField):
|
||||||
return db_field.formfield(widget=forms.TextInput(attrs={'class': 'vTimeField', 'size': '8'}))
|
kwargs['widget'] = forms.TextInput(attrs={'class': 'vTimeField', 'size': '8'})
|
||||||
|
return db_field.formfield(**kwargs)
|
||||||
|
|
||||||
# For ForeignKey or ManyToManyFields, use a special widget.
|
# For ForeignKey or ManyToManyFields, use a special widget.
|
||||||
if db_field.rel and isinstance(db_field.rel, (models.ManyToOneRel, models.ManyToManyRel)):
|
if db_field.rel and isinstance(db_field.rel, (models.ManyToOneRel, models.ManyToManyRel)):
|
||||||
# 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()
|
formfield = db_field.formfield(**kwargs)
|
||||||
formfield.widget.render = widgets.RelatedFieldWidgetWrapper(formfield.widget.render, db_field.rel)
|
formfield.widget.render = widgets.RelatedFieldWidgetWrapper(formfield.widget.render, db_field.rel)
|
||||||
return formfield
|
return formfield
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user