This is a utility shell script to speed up the process of setting up a Django project, from running multiple commands to simply running:
djsetup hello_world
WHAT THE SCRIPT WILL DO
- Create a folder in your Django projects folder for this new project (e.g.,
~/code/python/django/hello_world). - Create a
.venvPython environment within that folder and activate it. - Install Django in
.venv. django-admin startprojectyour projectpip freeze > requirements.txt- Create a
.gitignorefile and add.venv/to it. - Initialize git and make the initial commit.
IMPORTANT NOTE
This is a script for my machine, so it makes a few assumptions about the existence and location of certain folders.
For instance, I assume that the script djsetup.zsh lives in the ~/bin folder
and the django projects folder is located at ~/code/python/django. Adjust them according to your preference.
PREREQUISITES
Make sure you're using the zsh (check with echo $SHELL).
INSTRUCTIONS
- Create the file
~/bin/djsetup.zsh. - Make it executable (run
chmod a+x ~/bin/djsetup.zsh). - Add the
djsetup()function to your~/.zshrc.