﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14802	feature request: add a method to Fields that is used to render the field as read-only	nickname123	Greg Turner	"It is possible to override the default widget that is used to render a custom model field... however the hidden_widget is more difficult.  The only way appears to be on a per model basis by changing the widget in the model admin.  This can be very difficult/impractical when inheriting models that make use of the custom field with the field set to readonly in the model admin.

For example, a simple field that uses a custom widget:

{{{

class CustomFileWidget(forms.FileInput):
	return mark_safe(u""CustomFileWidget was used: %s"" % super(CustomFileWidget, self).render(name, value, attrs))
	
class CustomFileFormField(forms.FileField):
    def __init__(self, *args, **kwargs):
        kwargs['widget'] = CustomFileWidget
        super(CustomFileFormField, self).__init__(*args, **kwargs)
        
class CustomFileField(models.FileField):
    def formfield(self, **kwargs):
        return super(CustomFileField, self).formfield(form_class=CustomFileFormField,**kwargs)
}}}

		
		
However, there does not appear to be a kwarg for hidden_widget and using something like the following will not work:

{{{

class CustomFileFormField(forms.FileField):
    hidden_widget = CustomFileWidget
    widget = CustomFileWidget
class CustomFileField(models.FileField):
    def formfield(self, **kwargs):
        return super(CustomFileField, self).formfield(form_class=CustomFileFormField,**kwargs)
}}}
"	New feature	closed	contrib.admin	1.2	Normal	wontfix	sprintdec2010 hidden_widget		Design decision needed	0	0	0	0	0	1
