I am trying to pass timezone.now() + timedelta(days=-2)
and timezone.now()
as arguments in django model method but am getting
def performance(user, timezone.now() + timedelta(days=-2), timezone.now()):
^
SyntaxError: invalid syntax
I know the error is as a result of the concatenation but I dont know how to solve this problem.
class User(AbstractUser):
.........................
fields
.........................
def get_performance(self, timezone.now() + timedelta(days=-2), timezone.now()):
actual = Sum("scores", filter=Q(status="completed"))
q = self.taskassignt.filter(
due__gte=timezone.now() + timedelta(days=-2),
due__lt=timezone.now()
).annotate(actual=actual, total=Sum("scores"))
return (q[0].actual / q[0].total) * 100