I\'m writing a django model that allows my site to have coupons.
Coupons can have three types: lifetime account voucher, certain period of months voucher, certain numb
You could also use a list comp to filter false values:
if len([x for x in [self.months, self.dollars, self.lifetime] if x]) > 1: raise ValueError()
Or building off MRAB's answer:
if sum(map(bool, [self.months, self.dollars, self.lifetime])) > 1: raise ValueErrro()