Python Forum
[Django]calculate value in model - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: [Django]calculate value in model (/thread-25911.html)



[Django]calculate value in model - smabubakkar - Apr-15-2020

Hi I am new to Django

I have a Model with Buying and Selling Rate and have loaded data it.

Now i want to update the Model and a calculative column called Profit like:

Profit=models.FloatField(selling-buying)

It throws error.

What is the correct way to do it, how can i change value for the data which have been loaded earlier from python.

i know we have to do something in default=calculated_value

Kindly help.

Code: https://repl.it/repls/VigorousConsiderableVaporware


Error: