#3729: For integer field inside Model.save() is provided string value when
'choices' option is used
--------------------------+-------------------------------------------------
Reporter:  EntropyHacker  |       Owner:  adrian               
  Status:  new            |   Component:  Database wrapper     
 Version:  SVN            |    Keywords:  choices, integerfield
   Stage:  Unreviewed     |   Has_patch:  0                    
--------------------------+-------------------------------------------------
 I found that inside save() method of model field declared as
 PositiveSmallIntegerField actually is string! So instead 2 I have "2" as
 self.status value. If 'choices = STATUS_LIST' will be removed from field
 declaration bug will disappear and inside of save() I have integer as it
 should be.
 
 {{{
 from django.db import models
 import types
 
 STATUS_LIST = (
      (1, 'New'),
      (2, 'Public'),
      (4, 'Hidden'),
 )
 
 class Dummy(models.Model):
      name = models.CharField(maxlength=16)
      status = models.PositiveSmallIntegerField(default = 1, choices =
 STATUS_LIST)
 
      class Admin:
           pass
 
      def __str__(self):
           return self.name
 
      def save(self):
           print "Dummy.save status=%s, type=%s" % (self.status,
 type(self.status))
           assert type(self.status) == types.IntType, \
               "instead of IntType received %s, value is %s" %
 (type(self.status), self.status)
 
           super(Dummy, self).save()
 
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3729>
Django Code <http://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