python django fields and row calculation

2017-04-04 Thread sum abiut
Hi, I am working on an leave management system and I am having a some difficulties trying to figure out how to accomplished this scenario. for example i have a table of. when a user apply for a leave i want to get the previous total_leave_balance of the applicant and minus his/her current num_da

Re: python django fields and row calculation

2017-04-04 Thread Lachlan Musicman
Depends on your models, but write a small function that returns the balance? def balance(self): return self.entitlement - self.num_days (for instance) L. -- The most dangerous phrase in the language is, "We've always done it this way." - Grace Hopper On 5 April 2017 at 10:49, sum abi

Re: python django fields and row calculation

2017-04-04 Thread sum abiut
Thank for taking your time to respond. my problem is automating that, for example when a user apply for a leave i want the system to calculate and update the total balance automatically. But Since a user can apply for a leave more that once which mean a user can have more that one record of leave a

Re: python django fields and row calculation

2017-04-04 Thread Lachlan Musicman
Well, if it's on the user model as a function, then it will happen as soon as you call it. If they can have mulitple applications in process, then you will need to program your function(s) to account for that. As they say "there's more than one way to do it". You could add a "remaining days" var

Re: python django fields and row calculation

2017-04-05 Thread sum abiut
Thanks heaps this should get me started On Wed, Apr 5, 2017 at 2:42 PM, Lachlan Musicman wrote: > Well, if it's on the user model as a function, then it will happen as soon > as you call it. > > If they can have mulitple applications in process, then you will need to > program your function(s) t

Re: python django fields and row calculation

2018-06-11 Thread ijazz jazz
In short, a model's manager is an object through which Django models perform ... (For row-level functionality – i.e., functions that act on a single instance of a model object ... This has a single method, title_count() , which does the calculation. Best Python Training in Chennai