#23501: remove/add fields programatically in modelform fails in admin
-------------------------------+------------------------------------
     Reporter:  hadisunyoto    |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  contrib.admin  |                  Version:  1.7
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------

Comment (by hadisunyoto):

 A little update:

 i tried get_fields() method and still keep del intact, it turns out to be
 an error

 KeyError at /admin/thicknesses/thickness/0.55/
 'value'

 {{{

 21.    def __init__(self, *args, **kwargs):
 22.        super(ThicknessForm, self).__init__(*args, **kwargs)
 23.        instance = getattr(self, 'instance', None)
 24.
 25.        # edit
 26.        if instance and instance.pk:
 27.            del self.fields['value'] <--
 28.
 29.    class Meta:

 }}}

 occur in line 27

 i guess i have to forget about the form and put everything in admin then.
 What worries me is there will be several models that requires the clean()
 method in form to check related fields, that means that i have two places
 (form and admin) that handles the form, and i don't think that's a good
 approach

--
Ticket URL: <https://code.djangoproject.com/ticket/23501#comment:6>
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/069.358b696f4aec56c58b9f5787d39e2e41%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to