Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

469
Visualizações
hiding secret key in django project on github after uploading project

I uploaded my django project on github and I have a lot of commits on my project.

I don't want to delete my project and reupload it again.

what is the easiest way to hide secret key after uploading project to github and after a lot of commits?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In the same directory where manage.py is, create a file whose name is .env, and put inside it:

SECRET_KEY = '....your secret key ....' # --- the one indicated in your settings.py, cut an paste it here

where SECRET_KEY = '....your secret key ....' is the one indicated in your settings.py.
So cut this line from your settings.py and paste it in the .env file.

In the same directory, create a file whose name is .gitignore, and put inside it:

.env

Then in your settings.py, where previously you had SECRET_KEY = '....your secret key ....', put:

from decouple import config

SECRET_KEY = config("SECRET_KEY") # this is to replace the secret key you cut away before

then in your command prompts run:

pip install python-decouple
pip freeze > requirements.txt

then add, commit and push on Github.

Here you can find out more information on how .gitignore works.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda