#25942: TypedChoiceField.has_changed behaviour has changed between 1.8 and 1.9
---------------------------------+------------------------------------
     Reporter:  arthru           |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Forms            |                  Version:  1.9
     Severity:  Release blocker  |               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 arthru):

 In fact, in my case, the coerce is used using the field's to_python method
 as following (my mistake, sorry) :

 {{{
 from django.db import models
 from django.forms import TypedChoiceField

 CHOICES = [
     ('choice1', 'Choice 1'),
     ('choice2', 'Choice 2'),
     ('choice3', 'Choice 3')
 ]

 my_choices = models.CharField(
     max_length=7,
     choices=CHOICES,
     null=True,
     blank=True,
     default=None,
 )


 kwargs = {
     'label': 'Method',
     'choices': [
         ('', '---------'),
         ('choice1', 'Choice 1'),
         ('choice2', 'Choice 2'),
         ('choice3', 'Choice 3')
     ],
     'initial': None,
     'empty_value': None,
     'required': False,
     'help_text': '',
     'coerce': my_choices.to_python,
 }

 tcf = TypedChoiceField(**kwargs)
 # the following line did work in django 1.8
 assert not tcf.has_changed(None, '')
 }}}

 Overall, I detected that when using my model in a formset having an
 extra=1. When submitting without touching anything, the form is treated as
 a changed form due to this changed field (where it should be ignored as
 nothing was changed).

--
Ticket URL: <https://code.djangoproject.com/ticket/25942#comment:3>
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.25e000fab7cf41c64a09018156c101f5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to