Last active
July 18, 2021 02:11
-
-
Save sankalpjonn/7b1390add5e3c2e28721862233a87421 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
from django.db import models, transaction | |
class Account(models.Model): | |
balance = models.IntegerField(default=0) | |
user = models.ForeignKey(User) | |
def deposit(self, amount): | |
self.balance += amount | |
self.save() | |
def withdraw(self, amount): | |
if amount > self.balance: | |
raise errors.InsufficientFunds() | |
self.balance -= amount | |
self.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment