#15995: Problems in ModelForm._post_clean
------------------------------------+------------------------
               Reporter:  apollo13  |          Owner:  nobody
                   Type:  Bug       |         Status:  new
              Milestone:            |      Component:  Forms
                Version:  SVN       |       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         |
------------------------------------+------------------------
Changes (by kuba.janoszek@…):

 * ui_ux:   => 0


Comment:

 Personally I think that using "construct_instance" function inside form's
 _post_clean method is not good idea.
 Maybe it should me method? - If it would be a method it will be easy to
 change the way of instance construction.
 Everybody who is unhappy with it will have opportunity to change it
 easily.

 Here's my idea (should be part of django.forms.models.BaseModelForm class)

 {{
     def _construct_instance(self):
         opts = self._meta

         return django.forms.models.construct_instance(self, self.instance,
 fields=opts.fields, exclude=opts.exclude)

     def _post_clean(self):
         self.instance = self._construct_instance()

         # ... the rest of _post_clean method
 }}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/15995#comment:4>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to