A Complete Beginner’s Guide to Django

Anaconda Installation

Great so you’ve decided to install Django! Good for you mate!! So go ahead and install the Anaconda Python distribution.

Once you are done installing open your CMD or terminal. follow the following steps with me.

Creating the virtual environment

You might ask, why do I need a virtual environment. Well, the reason is you can easily manage multiple work-spaces or projects in one machine without any package dependency confliction.

So in your terminal follow these commands.

great! the above command will create a new Anaconda virtual environment for you, and we named it as myfirstDjangoProject.

Now we need to activate the project. So use the following command.

Wonderful! now let’s install Django using the following command.

This might take a few minutes, after that you should be ready to proceed with the rest of the steps.

Creating the Django Project

Go ahead and create a folder on your desktop.  Now navigate to the folder you created using the terminal if you closed the terminal by mistake that’s okay, just open the terminal window inside the folder you created. Then go ahead and activate your virtual environment using the following command source activate myfirstDjangoProject.

Now, I’m going to create the project, and I’m going name it as firstSite.

Now, cd into the firstSite, and list all the files, and you should see the following.

firstSite manage.py

Great! we are almost done. Now go ahead and type the final command.

In the above code, we are saying go ahead and run the Django server on port 8000, you can visit that URL at but you should get an error message saying “DisallowedHost at / Invalid HTTP_HOST header: ‘’. You may need to add ‘’ to ALLOWED_HOSTS” well, let’s edit our settings.py, go into the firstSite–>firstSite folder and you should see the settings.py Python file.

Open it with your favourite text editor, and look for the following line.  ALLOWED_HOSTS = []  and replace it with the following  ALLOWED_HOSTS = ['','']

Here what we are saying is we would like to run our Django web server up on port 8000 upon request. Make sure to save the file, and the run server again.

Here is the command  python manage.py runserver

Congraluation! You have successfully created your first Django Project!