Symons
Passionate developer with 3 years of building web apps with python Django. Symons is a graduate from Maseno University with Bsc Computer Science degree. He is mostly happy when his students make strides

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

 

automate django project creation demo

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

 

the file

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

 

file 3 bash

It should be in the root folder /home same place as .bashrc

Inside .bash_aliases add alias djangostart=’. djangostartproject’

 

automate with django

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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *