1 year ago

#259229

test-img

programmerBeginner

The best way for calculated fields in Django

I'm starting to create my first web application in Django. I'm dealing with backEnd part first. In my data structure I need to calculate some fields like average budget of employee's salary for each model object (company, department ..).

I found some ways to calculate and display calculated field in API.

  1. Add a property into model and override querySet for better performance.
  2. Calculate and add extra field in serializers and display it for API.
  3. Use build-in computedfields.models

I can not decide which way is best for calculating fields, what are pros and cons of each way.

Thanks for some advice.

python

django

django-models

django-rest-framework

calculated-field

0 Answers

Your Answer

Accepted video resources