﻿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
17031	Enable ModelForm to display as read-only	ferdonline@…	nobody	"It seems there is not an easy way to define a ModelForm as having all its fields ""read-only"", so that the form can be used for only-displaying info, for instance to a non-authenticated user.
I've seen several people looking for this feature with some nasty workarounds.

A +/- clean hack is to define a function in the child class that goes iterates over the fields and defines the disabled attribute to the corresponding widget, like:

{{{
def set_readonly( self ):
    for field in self.fields:                
        self.fields[field].required = False
        self.fields[field].widget.attrs['disabled'] = 'disabled'
    
}}}

is there a better way of doing this? If not, can you consider applying this solution to the main class (ModelForm)?

Cheers!"	New feature	closed	Forms	1.3	Normal	wontfix	read-only ModelForm		Unreviewed	0	0	0	0	0	0
