Six things I do every time I start a Django project

submited by
Style Pass
2022-06-23 19:00:05

I start a lot of projects. A lot! Django is my go-to framework for spinning up a quick personal project, and while it's a fantastic framework, a big part of the reason I love Django is that it feels familiar.

I have a lot of muscle memory for starting a new project. Here are six things that I do after I run django-admin startproject.

While it's one that you can get away with if you're keeping your source private, I reconfigure the SECRET_KEY as an environment variable on every new project. This helps you get started along the path of building a Twelve Factor App and means that making the repository public won't expose you to problems down the line.

Having the SECRET_KEY in a .gitignore'd .env file means that you can change it in each environment and specify your server's secret during your deployment. We're not going to talk about deploying applications today (I use django-up) but this strategy will allow you to specify the SECRET_KEY as an environment variable both locally and on your server.

If you're using pipenv the .env file will be automatically loaded when you run commands in your terminal. You can also use tools like direnv to load the .env file when you move into the directory.

Leave a Comment