Python Web Development with Django [Simple Guide to Your First Project]
Do you hear lots of buzz about Django? Absolutely, it has the huge demand in IT sector for web development.
But, many of the geeks are afraid to learn and to sail their boat into the web development.
I am not saying it is easy. But it is not 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 all you will learn at the end of this tutorial.
Python Web Development with Django
Django is the most versatile web development framework in Python. Django comes with all the major features that make the web development easy.
There are many alternatives for web development framework in Python. You can build your website using Bottle framework, you can use Flask framework as well…
Even though there are many alternatives for Django, it is the best choice for the various reason. 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…
You can use any of the Python 2 or Python 3 version for Django.
If you don’t have Python installed on your system, depending on your Operating system you can follow steps to install Python.
How to Install Django on Your System?
Django is basically a Python module. You need to install it on your system before you start.
For installation, you can use simple pip command.
Open command prompt or terminal in case of Linux. And run the following command.
pip install django
Note: pip in the above command is the tool which 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.
That’s it. Isn’t it so simple?
Command to Create Your First Project in Django:
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 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 the help to get more detail.
Change the current directory to 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.
How to Run Your First Django Project?
Here comes the first use of
To check if everything is running fine after installation of Django, start the web server.
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, port number of Django will be different.
Congratulation, you are all set to sail your boat.
What’s the next?
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.