Hi, everyone. Django Wan! I'm a newbie.
I'm asking you this question because I'm wondering where to define the constants to be used throughout the project while learning Django.
If it's my coding style, constnat.Make a py or something, and in it, I would have declared and used variables like IS_LOG_MODE = True, but by default, a file called setting.py was created.
Where do Django projects usually declare global constants? Of course, it doesn't matter where you go, but I'm asking you because I feel uncomfortable~
python django
There's no specific rule. In Django, settings.Put the global constant in py.
Save setting.py as follows
MY_GLOBAL = "VALUE"
In the file that you want to write this global constant,
from django.conf import settings
Like this, setting.Gets the constant of py. Or constants that only store global constants.You can make a py yourself and import it.
© 2024 OneMinuteCode. All rights reserved.