MLH-Fellowship / MLH-Fellowship/LearnForFree

[Bug] Unable to load .env to include secret key for local development

Open
#27 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Hi there,

I see a few bugs and misconfiguration on this project. In the settings.py file, environment variables were decoupled for the security measure which is all most necessary for the production of the site. But in the case of development purpose on the local machine, we need to create .env and insert those values for running our project. I tried to do it but couldn't able to load .env on both the parent folder of the project and the settings folder of the project.

To Reproduce
Steps to reproduce the behavior:

  • clone the project
  • Install all the dependencies in the newly created activate python environment
  • Migrate the DB schema and run the project with a newly created .env file with a configuration like this
    SECRET_KEY=ek0@9u(zemu^+%*-z3!&y9mu_7u+edg9%)c%423mdoec-mi*
  • Note this is a sample only. The key should not be publicly exposed.
  • Run the project: python3 manage.py runserver

secret

In order to solve for the short term, I just did the hardcoded on the settings.py to run it for development purposes.
SECRET_KEY=ek0@9u(zemu^+%*-z3!&y9mu_7u+edg9%)c%423mdoec-mi*

And removed the SECRET_KEY = os.environ.get('SECRET_KEY') code.

** Solution**
It should be properly configured. Here is the reference for it.

Expected behavior
Django project should expose the port localhost:8000 on the console and can be able to get access on the web browser.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with settings.py and reproduce the issue using a newly created .env file, the listed SECRET_KEY configuration, and python3 manage.py runserver. Check whether the project loads the environment value and reaches localhost:8000; done means the development server starts without hardcoding SECRET_KEY in settings.py.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.