I have the following directory structure:
The directory name is test_app
|-- __init__.py
|-- manage.py
|-- models.py
|-- views.py
I have a very basic question to ask, i place the following values inside my __init__.py
alpha = "123"
beta = "546"
How do i get the value of alpha and beta inside models, views and manage?
i tried the following:
from . import alpha
from test_app import alpha
both of them did not work, how do i do it?
__init__.pyis usually empty and indicates that files in your directory, in this case test_app can be imported. You could put your values in another .py file (example: constants.py) and do the following:Then import your constants:
The contents of constants.py would be
Then you would be able to use what ever values you stored in constants