#21464: readonly_fields is not resetted correctly
-------------------------------+--------------------
     Reporter:  fiomtec@…      |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  contrib.admin  |    Version:  1.5
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 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 = ()
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21464>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/060.b68a8e06be60360d84517d74eb1ec0d4%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to