Blog

How to Setup Django/python

February 22, 2019 by admin

This article will guide you to how you can setup Python django. This article also explain how you can Setup Python Environments, Virtual Environment , Installing pip , Setup Django project and run ,By Follow easy Steps.

First Step : Installation of Python

  • Download the current version of Python (2.7.1) from the Python Download site.
  • Double click on the icon of the file that you just downloaded and install it.
  • Complete the installation Wizard steps with default options untill you get to finish button.
    Installation is completed.

Second Step: is Setting up the Python Environment

  • Go to My Computer to the following directory C:\Python27. In that folder you should see all the Python files.
  • Copy Python Folder path form the window and close.
  • Right Click on My Computer click on properties.
  • Click on Advanced System Settings or Advanced.
  • Click on Environment Variables.
  • Under System Variables search for the variable Path.
  • Select Path by clicking on it. Click on Edit.
  • Scroll all the way to the right of the field called Variable value using the right arrow.
  • Add a semi-colon (;) to the end and paste the path (to the Python folder) that you previously copied. Click OK.

Third Step: Install Pip package management For python

We use pip(python package management) to install and manage software/module packages written in python.

Install on Mac:

-> Open command line terminal and run following command

sudo easy_install pip

Step Four: Install Virtual Environment(virtualenv) For Python

Open the terminal and write this command. This will install virtual environment

sudo pip install virtualenv

After installing we will need to create virtual environment. Now you will need to create folder when you are putting your other projects. In My case on desktop ”
pyenvoirment” folder.

Now, go into that folder

cd pyenvoirment

Now write this command in Terminal with environment name to create Virtual Environment.

virtualenv envMyVirtual

It will install the required folders.
Time to activate newly created virtual environment by typing the following command. Please Make sure you are in the virtual environment directory.

source envMyVirtual/bin/activate

You will see your terminal looks like below.

After Setting up Virtual Environment now next step is to install Django.

Step Five : Install Django

Now make sure you are in Virtual Environment Folder and install the Django using Following Command.

sudo pip install django==2.0.3 

It will download the Django project. Check the Django version using the following command.

python -m django --version  

Step Six : My First Django project

Type the following command to create project with necessary hierarchy of file will be created.

django-admin startproject first_django_project

Go into that folder by command

cd first_django_project

Now we have created the project. Now start the project server by typing the following command.

python manage.py runserver

By doing so it will start the development server, and we can access it via localhost:8000

Open the browser, and you will see the screen like below.

You can use Pycharm to open project and for further application development. Goto to Pycharm Site to download.

Finish. Thanks!

Leave a Reply

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