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.py
>     def CalcPoints(self):
>         return self.won*3 + self.draw


The python documentation has this to say about the '*' operator
(from: 
https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
)

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 
:  https://docs.djangoproject.com/en/2.2/ref/models/fields/#default

HTH,


-- 
Roger Gammans <rgamm...@gammascience.co.uk>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea23ce16123320b41ad5f468ebb742f1bcb25b37.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to