#27039: ModelFields with 'default' value set and 'required'=False in form does 
not
use default value
-------------------------------------+-------------------------------------
     Reporter:  Ivan Belokobylskiy   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Forms                |                  Version:  1.10
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:  default non-         |             Triage Stage:  Accepted
  required modelform                 |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

 The behavior you describe isn't what's implemented. Hopefully it's not
 documented anywhere. It should be possible to adapt your code. For
 example, this might work:
 {{{
 if not token:
     token = utils.generate_token()
     self.data['field_x'] = token
 }}}
 by inserting a value in `self.data`, the model fallback logic won't be
 triggered, I think. If you think we could improve the behavior and have a
 patch to propose, feel free to open a new ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/27039#comment:18>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d75de352909172bb16f5829fc86f2ae4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to