Omar,
When posting question to the list it's good practice to practice tell us a little bit about what your trying to do, and how what
actions cause the error to occur.
In this case though you only have a (single line in CalcPoints) which uses the '*' operator.
On Sat, 2019-04-06 at 10:35 -0700, omar ahmed wrote:
models.pydef CalcPoints(self):return self.won*3 + self.draw
The python documentation has this to say about the '*' operator
The
* (multiplication) operator yields the product of its arguments. The arguments must either both be numbers, or one argument must be an integer and the other must be a sequence. In the former case, the numbers are converted to a common type and then multiplied together. In the latter case, sequence repetition is performed; a negative repetition factor yields an empty sequence.Since you've provided a literal integer ( the '3') as one of your arguments, we can deduce the None value
is in self.won. Since you have 'declared' self.won as an IntegerField; we can see that as in the
normal case we should satisfy the first clause of the reference, "arguments must either both be numbers"
however so some reason self.won is None in your case.
Without seeing the rest of your code it's impossible to guess accurately but my instinct is your haven't
initialised your instance from the database (or set a won value when creating the object).
If you expected to have a default value you need to set one where you set up self.won see
HTH,
--Roger Gammans <rgammans@gammascience.co.uk>
No comments:
Post a Comment