1

I want to implement next situation in my save function in model: if factor_rate exists in database ( not None) -> than do something. But in my case 0 is acceptable value for me, user can provide this value in form. And I don't know how to separate None from 0. Do you have any idea?

if self.factor_rate:
    self.status = False
else:
    self.status = True
Shyrokoa
  • 223
  • 2
  • 11

1 Answers1

2

You check with is None:

if self.factor_rate is None:
    self.status = False
else:
    self.status = True

or shorter:

self.status = self.factor_rate is not None
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555