﻿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
21464	readonly_fields is not resetted correctly	fiomtec@…	nobody	"I have a model with three fields, one is a FileField, two I just complete myself on POST. The next time you see this model, every field is read only.

This is what I do in the modelAdmin:


{{{
    def get_form(self, request, obj=None, **kwargs):
        if obj:
            self.fields = ('tipo', 'fecha', 'fichero')
            self.readonly_fields = ('tipo', 'fecha', 'fichero')
        else:
            self.fields = ('fichero',)
}}}

Problem is: I create a new object, I enter and see this object, and when I try to create a new one, readonly_fields is still as it was in the first object, i.e., I need to do this for the form to allow me to upload a new file:


{{{
    def get_form(self, request, obj=None, **kwargs):
        if obj:
            self.fields = ('tipo', 'fecha', 'fichero')
            self.readonly_fields = ('tipo', 'fecha', 'fichero')
        else:
            self.fields = ('fichero',)
            self.readonly_fields = ()
}}}

"	Bug	closed	contrib.admin	1.5	Normal	invalid			Unreviewed	0	0	0	0	0	0
