DEV Community

Discussion on: How to protect your Django Secret and OAuth Keys [2024 revised]

Collapse
 
vladyslavnua profile image
vladyslav nykoliuk • Edited

you would just list it plainly as that: .env (unless it's not in the same directory as the gitignore file of course)

# .gitignore
.env
env/
...
Enter fullscreen mode Exit fullscreen mode
Collapse
 
hengage profile image
Henry Chizoba

Ok thanks for your response. I have 2 questions.

First, I can't seem to locate the 'gitignore file' on my django project directory.

Second is, the code:
from dotenv import load_dotenv
load_dotenv()

it brings an error saying "unresolved import 'dotenv' in my problem terminal.

I did install dotenov and correctly too. You might have an answer for me? I'm a beginner with django. Thank you

Thread Thread
 
vladyslavnua profile image
vladyslav nykoliuk

The .gitignore file is one you have to manually create, it doesn't come with the initial Django project directory. Make sure its in the same directory as your manage.py file, along with requirements, etc.

Thread Thread
 
vladyslavnua profile image
vladyslav nykoliuk

For the first one, the .gitignore file doesn't come with the initial Django project - you have to manually create it. Make sure it's in the same directory as the manage.py, requirements, etc.

For the dotenv, do the errors still show up after you run:

pip freeze > requirements.txt

?

Thread Thread
 
hengage profile image
Henry Chizoba

Thank you, i fixed it already. Thanks.