Creating .env file on the root of the project
Asked Answered
O

1

12

I am trying to download a Django project from github and one of the requirements is:"As the project uses python-decouple you will need to create a file named .env on the root of the project with three values, as following:

DEBUG=True
SECRET_KEY='mys3cr3tk3y'
DATABASE_URL='postgres://u_bootcamp:p4ssw0rd@localhost:5432/bootcamp

"

1.What(where) is the root part of the project, is it part of the project where are settings?

2.What kind of file should .env be?(python package I suppose)

3.Should name of the file be simply .env(or something.env)?

4.Is .env file going to be imported in settings file?

Outlast answered 14/4, 2017 at 17:8 Comment(0)
B
26
  1. What(where) is the root part of the project, is it part of the project where are settings?

    • Where your manage.py file is (that is your project root directory).
  2. What kind of file should .env be? (python package I suppose)

    • .env is a text file not a package.
  3. Should name of the file be simply .env (or something.env)?

    • Just .env
  4. Is .env file going to be imported in settings file?

    • No need to import, python-decouple automatically picks variables from there.

Read more about Where the settings data are stored? and Usage of python-decouple.

Breezy answered 14/4, 2017 at 17:21 Comment(5)
also, you need to mention that in .env the values should not be in quotesFroude
Late response @NikosVitaTopiko, but does that include when the SECRET_KEY includes # character? For instance, if SECRET_KEY=ABCD123#45. The query here: #17237350 suggests to add quotes.Acetylene
So how do you add .env to your server since it will be in .gitignoreFayefayette
@Martins Server should not be using .env, you should inject those environment variables directly (e.g. code deployment)Breezy
@Aamir Adnan I'm using python decouple adding my API keys to .bash_profile, will decouple config find the file?Fayefayette

© 2022 - 2024 — McMap. All rights reserved.