Django is a Python web framework, thus requiring Python to be installed on your machine. At the time of writing, Python 3.7.0 is the latest version.
To install Python on your machine go to this URL. Download the executable installer and run it. Check the box next to
Add Python 3.7.0 toPATH and then click
After installation check whether your installation is successful or not by checking it’s version. After installation, first restart the machine/pc and then open command line and check the python version by executing below command:
As django is framework of python ,hence we need to install django inside python .
Django can be installed easily using
In the command prompt execute the following command:
pip install django
This will download and install the latest Django release.
To verify that Django can be seen by Python, in the command prompt first type
python ,then at the Python prompt, try to import Django and then check the django version
Now all the setup is done. Lets swim into code and make a very simple web project to show something.
Now create a project executing below command in the command line.
django-admin startproject mysite
This will create a directory called mysite. Within that directory, you have another one called mysite, along with a manage.py file. The manage.py file lets you easily interact with your project via the command line. The contents of the second mysite directory contain your settings and urls mainly.
Full structure of the project is delineated below.
mysite/ - Simple container, Call whatever you want. ├── mysite/ - Actual project directory. │ ├── __init__.py - Tells python this is a Python package. │ ├── settings.py - Settings for the project. │ ├── urls.py - URL rules. Django docs aptly describes as your table of contents. │ └── wsgi.py - WSGI magic begins here. Worry about this when it comes time to actually deploy to a server. └── manage.py - Lets you interact with your project via the command line.
As our project is created which is default one , we will check whether it is working perfectly or not. Lets run the project by executing following command:
python manage.py runserver
If you open the browser and go to http://127.0.0.1:8000/ this address and find something like below then everything is working as expected.
That means we have created a django project successfully. yeahhh….
Off-course we will see what and how we will go forward in the next consecutive tutorials.