Opened 10 years ago

Closed 10 years ago

#6960 closed (fixed)

PositiveSmallInteger comes with unicode value from admin

Reported by: kmmbvnr@… Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: type error nfa-fixed
Cc: Triage Stage: Fixed on a branch
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


If i save this model from admin, the type_x field comes as unicode.
When getting existing instances, the type_x field have int type.

Choices = (                                                                     
class Test(models.Model):                                                       
    type_x  = models.PositiveSmallIntegerField(choices=Choices,default=1)       
    def save(self):                                                             
        assert isinstance(self.type_x, int)                                     
    class Admin:                                                                

Change History (3)

comment:1 Changed 10 years ago by Karen Tracey <kmtracey@…>

Triage Stage: UnreviewedFixed on a branch

I suspect this has the same root cause as #6853. For some reason when the old manipulator code creates a new object for a field with choices set, the field value is not an integer type but rather the unicode representation of the integer. This is not a problem on newforms-admin.

comment:2 Changed 10 years ago by Karen Tracey <kmtracey@…>

Keywords: nfa-fixed added

comment:3 Changed 10 years ago by Brian Rosner

Resolution: fixed
Status: newclosed

This is no longer a problem since the merge of newforms-admin in [7967].

Note: See TracTickets for help on using tickets.
Back to Top