In Django, Accessing Attributes Across Models and Apps -


i have function in file (services.py):

def balance(revenue, expenses):     bottom_line = revenue - expenses     return bottom_line 

the revenue model inside revenue app:

class revenue(model.models):     revenue = model.decimalfield() 

the expenses model inside expenses app i'd calculation on save , populate "bottom_line" field:

class expenses(model.models):     expenses = model.decimalfield()     bottom_line = model.decimalfield()      def save(self, *args, **kwargs):         bottom_line = balance(revenue, self.expenses)         super(expenses, self).save(*args, **kwargs) 

how access revenue attribute during save override on model above? need queryset bottom_line attribute expenses model?


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -