I think you are trying to sum up the value of two model fields and store 
them in some other field. 


so for that u can proceed from base. 

simple you just have to update that field in save method

for example : 
 *class Student(models.Model):*
       maths_score = models.DecimalField()
       english_score = models.DecimalFIeld()
       Total_score   = models.DecimalField(default = 0)

       *def save(self, *args, **kwargs):*
*          self.Total_score  = self.maths_score  + self.english_score*
          super(Student, self).save(*args, **kwargs)



or you can proceed with clean() method also. 
On Tuesday, June 15, 2021 at 11:34:37 AM UTC-7 adesolar...@gmail.com wrote:

> How do I add two models together in the database, two different 
> DecimalField. 
> i.e math_score + eng_score = total_score
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/81d7b7b1-9521-47b1-9fef-91be3ba4c952n%40googlegroups.com.

Reply via email to