Tutorial #1: Create a Local Variable on Your System

For macOS or Linux:

Step 1: Open the Terminal.

Step 2: Determine which shell you are using. Generally, macOS and many Linux distributions use bash or zsh. You can find out with the command:

echo $SHELL

Step 3: Based on the shell you use, choose one of the following files to edit: .bashrc for Bash or .zshrc for Zsh. This file is located in your home directory (~).

Step 4: Open your shell’s configuration file with a text editor. For example, if you use Bash:

open -a TextEdit ~/.bashrc

If you use Zsh:

open -a TextEdit ~/.zshrc

Step 5: Add the environment variable at the end of the file. For example, to define DJANGO_SECRET_KEY, write:

export DJANGO_SECRET_KEY='your_secret_key_here'

Step 6: Save the file and close the editor.

Step 7: To apply the changes, close your terminal and open a new session, or manually load the configuration file using the source command. For example, if you use Bash:

source ~/.bashrc

If you use Zsh:

source ~/.zshrc

Step 8: Verify that the environment variable is set correctly with:

echo $DJANGO_SECRET_KEY

For Windows:

Step 1: Search for “System” from the Start menu and select “System Settings.”

Step 2: Go to “Advanced system settings” and then to “Environment Variables.”

Step 3: Under “Environment Variables,” click “New” to create a new environment variable.

Step 4: In the “Variable name” field, enter DJANGO_SECRET_KEY. In the “Variable value” field, enter your secret key.

Step 5: Click “OK” on all open windows to save the settings.

Step 6: To verify that the variable has been set correctly, you can open a new Command Prompt and use the echo command:

echo %DJANGO_SECRET_KEY%