I observed a weird thing with the integer field defined inside a model
class. Suppose I have

SEX_TYPE_CHOICES = (
    (1, 'male),
    (2, 'female'),
)

class Person(meta.Model):
    sex = meta.Integerfield(choices=SEX_TYPE_CHOICES)
    def is_male(self):
        if self.sex == 1:
            return True
        else:
            return False

The problem I have is if I try this method is_male() under django
python shell, it works perfectly fine. But it always fails when invoked
from web "views". I have to change self.sex ==1 to self.sex == "1". Did
I miss something completely or is it a bug?

Reply via email to