title: Implementing a referral program on a Django website
body: <p>I am working on a cashback website. Right now the code is just adding the current balance of the referred user($0) to the balance of the referrer, how can i link the two users so that a fraction of the referred user's future earnings will be added to the balance of the referrer</p>
  
  <p>def referral_registerPage(request, slug):</p>
  
  <pre><code>form = CreateUserForm
  
  if request.method == 'POST':
  
      customers = Customer.objects.all()
  
      form = CreateUserForm(request.POST)
      if form.is_valid():
          user = form.save()
          username = form.cleaned_data.get('username')
          messages.success(request,'Account was created for ' + username)
  
          '''Get slug that was used to register account.'''
          user_slug = slug
  
          '''get user id by splitting user_slug, b = user id'''
          a,b = user_slug.split('-')
  
          '''customer that owns the referral link'''
          customer = customers.get(user=b)
  
          '''customer that registered through the referral link'''
          referred = customers.get(user=user)
  
          payment = customer.payment #payment details of the customer
          payment.current_balance +=  referred.payment.current_balance
          payment.save()
  </code></pre>
  
  <p>model i'm trying to update</p>
  
  <p>class Payment(models.Model):</p>
  
  <pre><code>customer = models.OneToOneField(Customer, on_delete=models.CASCADE, 
  null=True, default=None)
  
  total_amount_paid = models.DecimalField(max_digits=20,decimal_places=2, 
  null=True, default=0)
  
  current_balance = models.DecimalField(max_digits=20,decimal_places=2, 
  null=True, default=0)
  
  confirmed_orders = models.CharField(max_length=100, null=True, default=0)
  </code></pre>