Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Django]calculate value in model
#1
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:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: View is unable to find attributes of database model pythonpaul32 0 480 Dec-07-2023, 06:38 PM
Last Post: pythonpaul32
  Querying Django model db - from Jose Portilla’s Udemy course Drone4four 2 1,657 Aug-09-2022, 09:25 AM
Last Post: Addweb
Photo After using models.Model on my class Im getting 'ImproperlyConfigured' error Django khavro 1 2,150 Apr-05-2021, 03:11 PM
Last Post: SheeppOSU
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,245 Jun-30-2019, 12:21 AM
Last Post: scidam
  Need your help to fix my database relationship in Django model PrateekG 0 2,631 Jul-02-2018, 11:08 AM
Last Post: PrateekG
  Django not saving model in management command F2Andy 1 3,225 Jun-02-2018, 03:17 PM
Last Post: F2Andy
  Django model.py model.foreignkey() HenryJ 1 3,177 Feb-09-2018, 04:21 AM
Last Post: DocSeussMan
  How do I make a Django model from a tab-delimited data file? newbietostuff 0 2,501 Jan-09-2018, 02:44 AM
Last Post: newbietostuff
  Django field model for HTML parser? Drone4four 0 4,117 Nov-15-2017, 02:43 AM
Last Post: Drone4four

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020