title: Django Model validation based on a field value of another Model
body: <p>I have this Django model:</p>
  
  <pre><code>   from accounts.models import Account    
  
     class BankOperation(models.Model):     
         created_at = models.DateTimeField(auto_now_add=True)
         account = models.ForeignKey(Account, on_delete=models.CASCADE)
         operation_import = models.FloatField(default=0.0)          
  </code></pre>
  
  <p>I want to make sure that the <code>operation_import</code> is not higher than <code>account.balance</code>
  what is the official way to this? I have seen some answers talking about overriding the save() method but others advise against it.</p>
  
  <p>should i add a pre-save signal and throw some kind of exception?</p>
  
  <p>Is there a way to create a field validator that accepts parameters?
  so maybe something like: </p>
  
  <pre><code>   def validate_bank_operation_import(value, account_balance): 
     if value &gt; account_balance:
           raise ValidationError("Bank operation import is higher than account balance!")
  </code></pre>
  
  <p>and inside my model i change the field to:</p>
  
  <pre><code>operation_import = models.FloatField(default=0.0, validators=[validate_bank_operation_import])
  </code></pre>
  
  <p>But can i pass parameters to a validator? if yes, how do I do it?</p>
  
  <p>perhaps there is another to do this validation!</p>