Automate Django Project Creation
If you are learning Django you must be creating several projects and the process is tiresome and a time boring. So I got an open-source python script that automates the whole process and leaves you with a running server. Here is what it does on your behalf:
- Creation of the project folder
- Creating and activating the virtual environment
- Updating pip to the latest version
- Installing Django(latest stable version)
- Starting Django project
django-admin startproject
- Starting an app
python manage.py startapp
- Writing to settings.py, urls.py, views.py, templates
- Making migrations and migrating them
- Finally running server
python manage.py runserver
So We are going to Automate Django Project Creation
All this with just one command Isn’t that cool? Check Demo below
Setting Up
Before we can start using this script we must set up some things.
1. Create a bin directory on your /home folder open terminal and type:
mkdir bin
2.Download djangostartproject script from this repository and place djangostartproject file inside bin folder/directory
3. Add the path to the above file to .bashrc file you should find it in your home directory ( click C+H
if you can’t see it )
add this line at the end of .bashrc file
export PATH=$PATH:/home/USER/bin/ USER being the logged-in user
to allow our script to change into a new directory we need to:
4. Create a .bash_aliases file if you don’t have one
It should be in the root folder /home same place as .bashrc
Inside .bash_aliases add alias djangostart=’. djangostartproject’
We are ready to run it
Create any directory and type
symons@symons-macbookair:~/Desktop/djangostart$ djangostart myproject
At some point, it will ask you to insert the app name, do that and enter to let it proceed.
if you visit http://127.0.0.1:8000/ you should see the first index page. Home:
To contribute just make PR
That was all about how to Automate Django Project Creation
Thank you for reading