Saving data in a inherited django model
        Posted  
        
            by 
                aldeano
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by aldeano
        
        
        
        Published on 2011-01-07T22:13:44Z
        Indexed on 
            2011/01/08
            3:53 UTC
        
        
        Read the original article
        Hit count: 254
        
I'm building an app to save data and some calculations made with those datas, the idea is keep the data in one model and the calculations in other. So, the models are like this:
class FreshData(models.Model):
    name = models.CharField(max_length=20)
    one = models.IntegerField()
    two = models.IntegerField()
    def save(self, *args, **kwargs):
        Calculations()
        Calculations.three = self.one + self.two
        super(FreshData, self).save(*args, **kwargs)
        Calculations.save()
class Calculations(FreshData):
    three = models.IntegerField()
I've got a valueerror pointing out "self.one" and "self.two" as without value. I keep the idea in witch my design is wrong and django has a simpler way to store related data.
© Stack Overflow or respective owner