Thanks man.👍

On Wed, Jun 16, 2021, 5:22 PM Ayush Bisht <bisht.ayush2...@gmail.com> wrote:

> 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 a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/qsaj_ELIfgA/unsubscribe.
> To unsubscribe from this group and all its topics, 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
> <https://groups.google.com/d/msgid/django-users/81d7b7b1-9521-47b1-9fef-91be3ba4c952n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CABGdKQw3004v-NOK1hC56WrrpjmnXJ_fSL1BAN0kNXcJq5dMPw%40mail.gmail.com.

Reply via email to