﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3729	For integer field inside Model.save() is provided string value when 'choices' option is used	EntropyHacker	nobody	"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()

}}}"		closed	Database layer (models, ORM)	dev		worksforme	choices, integerfield		Unreviewed	0	0	0	0	0	0
