Re: Stuck with Calculated feild

2020-09-25 Thread Frederic Salvetat
Hi Eankomah, You have several solution depending upon your need: > Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit : > Hi all am stuck at getting total_price Calculated in my model > > class inventory(models.Model): > def __str__(self): > return self.name > ...

Re: Stuck with Calculated feild

2020-09-25 Thread Frederic Salvetat
Hi Eankomah, You have several solutions depending upon your need: *>Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :* *>Hi all am stuck at getting total_price Calculated in my model* *>* *>class inventory(models.Model):* *>def __str__(self):* *>return self.name* *> ...

Re: Stuck with Calculated feild

2020-09-23 Thread Kasper Laudrup
Hi Harish, On 23/09/2020 11.27, Harish Thiyagharajan wrote: I think you mailed me instead of mailing someone No. If you look at the mail header, you can see this was sent to the django-users mailing list. Kind regards, Kasper Laudrup -- You received this message because you are subscribe

Re: Stuck with Calculated feild

2020-09-23 Thread Harish Thiyagharajan
I think you mailed me instead of mailing someone On Wed, Sep 23, 2020 at 2:47 PM Kasper Laudrup wrote: > Hi eankomah, > > Completely unrelated, but:> unit_price = models.FloatField() > Don't use floats for money. It will give you all kinds of problems with > rounding errors etc. > > Assumin

Re: Stuck with Calculated feild

2020-09-23 Thread Kasper Laudrup
Hi eankomah, Completely unrelated, but:> unit_price = models.FloatField() Don't use floats for money. It will give you all kinds of problems with rounding errors etc. Assuming this is just a hobby project, it's probably fine, but otherwise consider looking into something like: https://

Re: Stuck with Calculated feild

2020-09-22 Thread dr neyx de godlove
hi there you can create another method for that class that calculates the total as @property def get_total_price(self): total_price = self.unit_price * self.quantity return total_price On Wed, Sep 23, 2020 at 8:24 AM eankomah wrote: > Hi all am stuck at getting total_price Calculate

Stuck with Calculated feild

2020-09-22 Thread eankomah
Hi all am stuck at getting total_price Calculated in my model class inventory(models.Model): def __str__(self): return self.name category = models.ForeignKey(Category, null=True, on_delete = models.SET_NULL) Supplier = models.ForeignKey(Supplier, null=True, on_delete = model