Re: Calculated feild in models

2020-09-19 Thread EA Media House
Alright On Sat, 19 Sep 2020 at 21:32, Arpana Mehta wrote: > You can use @property > > On Sat, 19 Sep 2020, 20:45 eankomah, wrote: > >> I have two fields: >> quantity = models.FloatField() >> unit_price = models.FloatField() >> >> and i want ot do someting like this >> >> >> total_pr

Re: Calculated feild in models

2020-09-19 Thread Arpana Mehta
You can use @property On Sat, 19 Sep 2020, 20:45 eankomah, wrote: > I have two fields: > quantity = models.FloatField() > unit_price = models.FloatField() > > and i want ot do someting like this > > > total_price = models.FloatField('unit_price' * 'quantity') > > Thanks > > -- > You

Re: Calculated feild in models

2020-09-19 Thread Mohammad Ahshan Danish
Create a model and add functions if you want to go more deep use Model-manager. On Sun, Sep 20, 2020 at 12:27 AM coolguy wrote: > Create a function at class level like this.. > > *class xxx(models.Model):* > quantity = models.FloatField() > unit_price = models.FloatField() > >

Re: Calculated feild in models

2020-09-19 Thread coolguy
Create a function at class level like this.. *class xxx(models.Model):* quantity = models.FloatField() unit_price = models.FloatField() * def get_total_price(self):* return self.quantity * self.unit_price On Saturday, September 19, 2020 at 11:15:30 AM UTC-4 e

Calculated feild in models

2020-09-19 Thread eankomah
I have two fields: quantity = models.FloatField() unit_price = models.FloatField() and i want ot do someting like this total_price = models.FloatField('unit_price' * 'quantity') Thanks -- You received this message because you are subscribed to the Google Groups "Django users" gr