Skip to content

Store sensitive data

Jimmy Oty edited this page Nov 30, 2022 · 1 revision

.env

Store sensitive data in the .env file

he .env file will be hidden automatically from the repo because it should contain sensitive information of the project such as the SECRET_KEY. After cloning the repo go on and follow these steps:

In the root directory of this Project, (Inside the folder named community), create a file called .env After creating the file, write the following lines:

    1. SECRET_KEY=your_secret_key
    2. DEBUG=True

This should do the trick, try running the server to check for any errors after creating your .env file

```python 
   python manage.py runserver
```

Note Generating Your Own SECRET_KEY

To generate a new key, use the get_random_secret_key() function present in the django.core.management.utils that returns a 50 character string of random characters. You can open the python shell by typing this command first to execute the get_random_secret_key

python manage.py shell

After opening shell, execute the following code to generate your random key

>>>from django.core.management.utils import get_random_secret_key
>>>print(get_random_secret_key())

Copy the key generated and place it in your SECRET_KEY variable in the .env file. There should be no whitespace around the variable

Clone this wiki locally