Business logic constants

28 views
Skip to first unread message

yuriy polonskiy

unread,
May 30, 2021, 7:17:10 AM5/30/21
to Django users
When working with business logic implementation code and you do not want use magic numbers in the code - where is the best place to put all those CONSTANTS ? Django settings file ?

Derek

unread,
May 31, 2021, 1:35:11 AM5/31/21
to Django users
There are many types of constants. We have a 'utils' directory (at same level as 'apps') and under that 'constants' sub-directory - with different files for different types of constants that are generally applicable across all apps.  But because we have lots of client-specific constants and coding of their business rules, those sit under their own structure elsewhere.  Using imports though, makes it relatively easier to reorganise over time if you need to.

The Django settings file is really only for constants related to starting up the program itself (and in our case a single flag to track who the client is). 

yuriy polonskiy

unread,
Jun 3, 2021, 5:45:26 AM6/3/21
to Django users
Thank for your response
Reply all
Reply to author
Forward
0 new messages