Hello friends, welcome to the very first post of this website. Here we are going to learn Python Django Framework. This is python django tutorial for beginners. If you are an absolute beginner in python django framework then you came into right place. I will be using windows operation system. Though you can still follow this tutorial using Mac or Linux. So lets start.
- 1 Python Django Tutorial for Beginners – Overview
- 2 Python Django Tutorial for Beginners – Configuration
- 3 Python Django Tutorial for Beginners – Your First Django Project
Python Django Tutorial for Beginners – Overview
To move ahead in this python django tutorial for beginners you should have the basic knowledge of python programming. As we are directly moving on to web development using python django framework, its highly recommended that you know the basics of python.
Though using an IDE is not necessary you can also go the text editor way. But I will be using PyCharm IDE by JetBrains. You can download this IDE from the link given below.
What is Python Django?
As the punchline says Python Django is The web framework for perfectionists with deadlines. So it is a web framework. We can develop Web Applications quickly using this framework.
Python Django Tutorial for Beginners – Configuration
Downloading and Installing Python
- Go to this link and download the python installer according to your operation system.
- Once you got the executable (I am assuming you are on windows) open it.
- Don’t install in the default location by choosing install now (because the path is too long 😛 ), instead select customize location.
- Now continue the installation and while installing select the location shown in the below image. (You can change the location but keep it short and the folder name should not contain spaces)
- Now once the installation is finished you need to setup some environment variables.
Setting Up Environment Variables
To complete the installation you need to setup python environment variables. Follow these steps to set environment variables.
- Go to your python installation directory (c:\Python35) and copy the address.
- Now go to environment variables (search environment variables)
- Click on Edit the System Environment Variables.
- Now in the system environment variable area click on new and in the name type path and in the value paste your path. (see the below image for clarification)
- As you can see I have pasted one more address which is inside the python installation directory. You need to paste this address as well (both address are seperated by coma). Now click ok and apply the changes.
- Lets test the installation is successful or not. So open Powershell in administrator mode. and type the following command.
- With the above command if you are getting the following result then you are done with python installation.
- As you can see the commands are working on powershell, it means python installation is successful.
We have done with installing python. Now lets install Django.
- Type the following command inside Django and hit enter.
- The above command will install the latest version of django. It may take some time depending on your internet speed. Once the command is completed. Run the following command to confirm the installation.
- The above command will give the following result.
- If you are seeing the result as shown in the screenshot then BINGO! you have done with django installation.
Python Django Tutorial for Beginners – Your First Django Project
Creating a Project
Now we will create our very first django project. Follow these steps.
- In power shell navigate to the directory where you want to create your project. In my case I am using my drive D:.
- Now to create a new project type the following command and hit enter.
django-admin startproject MyDjangoApp
- In the above command MyDjangoApp is the name of our project, you can change it to anything you want (Just don’t use spaces)
- After running the command check the directory that you selected while creating project.
- As you can see a folder is created with our project name.
Creating our Server
- Now come back to powershell, and navigate inside the project directory.
- Inside your project there is a python file manager.py. This file comes up with a bunch of features that we will use. For the detailed description of this file visit the official documentation.
- Now run the following command to start your development server.
python manage.py runserver
- You will see the following result.
- As you can see the development server is started at http://127.0.0.1:8000/ , type it in your browser to test. You will see the following result.
Bingo! your development server is working perfectly. Now I am wrapping up this Python Django Tutorial for Beginners here. In the next post we will start doing some cool things in our Django Project. And yes feel free to leave you comment if you have any queries or confusions related to this Python Django Tutorial for Beginners. Thank You 🙂