How can i hide database information like passowrd and host in settings.py so i can deploy my website from github repo
You donât. You set up your settings to get that information from outside your project - like from environment variables.
See:
- Deployment checklist | Django documentation | Django
- Episode 16 - Setting Your Sites ¡ Matt Layman
-
django-environ
(Among many other available resources)
yes, i did with .env file i used python-decouple it worked locally but when i push the code to github and use this project to deploy it on railway give me this error in âdeploy logâ
the error:
File â/opt/venv/lib/python3.10/site-packages/decouple.pyâ, line 90, in get
raise UndefinedValueError(â{} not found. Declare it as envvar or define a default value.â.format(option))
decouple.UndefinedValueError: DB_NAME not found. Declare it as envvar or define a default value.
if i replced decouple.config(âVALUEâ) with os.environ.get(âVALUEâ) ,âŚwill it work?
This all depends upon your deployment process.
Since your .env
files or other environment settings arenât going to be in your repo, you have to figure out how youâre going to get those settings deployed to your target production environment.
i solved the problem thanks , i set Variables inside railway and it worked!
pls can you help me out because i am having the same challenges?
We can try, but I would suggest that you open up a new topic and provide all the details about the challenges you are facing.