Answer the question
In order to leave comments, you need to log in
Competitive requests in django?
Hello! Suggest a solution. There is a Profile model with a balance field, which is stored in the database in decimal.
The Profile model has a method that changes the balance:
def update_profile(self, amount):
self.balance += amount
if self.balance < 0:
return False
else:
self.save(update_fields=["balance"])
return True
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question