0

When writing functions for views, should they be placed within the specific views, outside of the views within views.py or inside a separate script such as viewsfunctions.py?

Is there any advantage/requirement for any of these options?

As an example, if we were writing a function to convert units of weight from one to another for unified measurement, where should this function be written?

Evelyn
  • 19
  • 5
  • Best practice is to place the utilities functions like these in core/utils.py as they might be useful in other views / apps as well and resuse by importing. Related: https://stackoverflow.com/questions/3295268/where-should-utility-functions-live-in-django – Aadarsha May 16 '22 at 11:54

0 Answers0