How can I create a Django Model for Funds Transfer in a Banking Application

I’m a Django developer with a project to create a banking application. One of the biggest problems is fund transfers between users. To achieve this, I need to design a Django model that includes both a sender and a receiver for fund transfers so that when the sender sends the funds, it will update the receiver’s ‘account_balance’ field in the ‘account’ model. How can I create a ‘Transfer’ model that includes a sender and a receiver in one model, and how can I differentiate between the sender and receiver when making fund transfers in the ‘views.py’ file?

my models:

class Account(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    account_number = models.IntegerField()
    account_balance = models.DecimalField(max_digits=12, decimal_places=6)


class CustomUser(AbstractUser): 
     username = models.CharField(max_length=30) 
     full_name = models.CharField(max_length=100) 
     phone_number = models.CharField(max_length=16) 
     address = models.CharField(max_length=200) 
     date_of_birth = models.DateField(blank=True, null=True) 
     gender = models.CharField(max_length=20, choices=GENDER) 
     email = models.EmailField(_("email address"), unique=True) 
  
     USERNAME_FIELD = "email" 
     REQUIRED_FIELDS = ['username'] 
  
     objects = CustomUserManager() 
  
     def __str__(self): 
         return str(self.username)

Can you please provide a detailed breakdown of the key components this model should have, including fields, relationships, and any security measures or transaction management techniques I should implement?

  • 1

    This question is way too broad for SO. We can help you with specific problems you encounter while getting your code to work, but can’t provide you with personal suggestions. Please see How to Ask and the question checklist.

    – 




  • As a general rule, we don’t design things here, or help you decide what the program needs to do. We deal with questions about how to write the code that does a specific, clearly defined thing; or about why a specific attempt fails in a specific way (focused on the specific part that went wrong).

    – 

Leave a Comment