title: Django Set a Formula for field
body: <p>I want to set manual arithmetic formula of a field in a model, the formula changes from object to object of the model and is set by some superuser and sets it depending on the foreign model name.</p>
  <pre><code>class Strategy(models.Model):
   name = models.CharField(max_length=30, unique=True)
  
  class Line(models.Model):
   strategy = models.ForeignKey(Strategy,on_delete=models.CASCADE)
   startvalue = models.FloatField(default=0)
   endvalue = models.FloatField(null=True,blank=True)
   target = models.FloatField(default=0)
   alpha = models.FloatField(default=0)
  </code></pre>
  <p>So, Here there will be many strategies, And for each strategy I want superuser to map an arithmetic formula for alpha in terms of startvalue, endvalue, target, there will be many strategies and hence many formulae for alpha</p>
  <p>for example, if a strategy is</p>
  <blockquote>
  <p>s1 then alpha = 100*(startvalue+endvalue*target)</p>
  <p>s2 then alpha = startvalue-endvalue*target</p>
  </blockquote>
  <p>Like this, the superuser needs to set the formula of alpha for a strategy through <strong>GUI</strong> so that all Lines with that strategy have that formula for alpha.</p>
  <p>How to implement this? Please help me, I'm stuck here for more than two days.</p>