Do you hear lots of buzz about Django? Absolutely, it has a huge demand in the IT sector for web development.
But, many of the geeks are afraid to learn and to sail their boats into web development.
I am not saying it is easy. But it is not as difficult as you think. And gradually going through this tutorial, you will find yourself more comfortable.
Making this tutorial on Python web development with Django more simple and practical.
Here is what you will learn at the end of this tutorial.
Django is the most versatile web development framework in Python. Django comes with all the major features that make web development easy.
There are many alternatives to the web development framework in Python. You can build your website using the Bottle framework, you can use the Flask framework as well…
Even though there are many alternatives for Django, it is the best choice for various reasons. It is highly scalable and coding is simple as you do for Python.
If you are interested in Python and web development, Django is one of the best choices.
So, let’s start…
Table of Contents
You can use any of the Python 2 or Python 3 versions for Django.
If you don’t have Python installed on your system, depending on your Operating system you can follow steps to install Python.
Django is basically a Python module. You need to install it on your system before you start.
For installation, you can use a simple pip command.
Open command prompt or terminal in the case of Linux. And run the following command.
pip install django
Note: pip in the above command is the tool that is used to manage the Python modules. And it comes pre-installed with the latest Python version. You don’t need to install it explicitly.
For Git User:
Django is open-source and available at Git.
If you are familiar with Git, you can also clone the Django project from Git to install on your system.
If you are new to Git, check our Git tutorial to learn git commands.
That’s it. Isn’t it so simple?
Creating a virtual environment to run your Django project is important.
You can installs and manage all the required libraries in the virtual environment.
If you are new to the virtual environment, check how to create a virtual environment. These are just simple commands.
Once you create a virtual environment, activate your environment before starting to develop a Django project. (Steps to create and activate a virtual environment are shared in the above tutorial link).
You have built your boat. You need to put it against the tide of seashores.
Without thinking much, run the following command.
django-admin startproject myFirstProject
myFirstProject is the name given to the project. You can give it any other name.
It will create a new directory with the project name. It will consist of different files in the hierarchy as shown below.
myFirstProject/ manage.py myFirstproject/ __init__.py settings.py urls.py wsgi.py
Initially, we need to understand
Here manage.py is a script to interact with the project through the command line such as starting the web server, creating the new app, synchronize the database…
For more, you can seek help to get more detail.
Change the current directory to the project directory. And run the command.
python manage.py help
It lists all of the commands you can use with
I will describe the use of other files in the upcoming tutorials where we will use it practically.
Here comes the first use of
To check if everything is running fine after the installation of Django, start the webserver.
python manage.py runserver
It starts the localhost server on your local system for development. Open the localhost server name in the browser.
8000 is the default port number. If this port is used by any other application on your system, the port number of Django will be different.
Congratulation, you are all set to sail your boat.
If you want to be the excel Django web developer, you should be familiar with all the Python terminologies for web development.
This is all about a simple guide for beginners to start Python web development with Django. In the next tutorial, I will share how Django App is different from the project and how to build your first Django App.
Stay tuned and happy web development.