A Journey To Python Django
Basic understanding of Django with a small project
What is Python Django ❓
Django is a Python web development framework which helps us to develop a full-stack web application much easier. It follows the model-template-views architectural pattern. that is, It is a collection of three important components: Model, View and Template. The Model help us to handle database. The Template deals with the user interface part. The View is execute the business logic and interact with a model to carry data and renders a template.
Django have many Predefined templates and tables which we can accessible in our project.
Relation with Python and Django 🤝
Python is a programming language that’s used for many different applications like, artificial intelligence, machine learning, game development, etc. while, Django is a Python framework for full-stack web application development and server development.
For running a Django project, our system need to be installed with python
Install Python
Get the latest version of Python at https://www.python.org/downloads/ or with your operating system’s package manager.
You can verify that Python is installed by typing python from your terminal;
You should see something like:
Python 3.x.y
[GCC 4.x] on linuxInstall Django
Open your terminal and run the following command.
>>>pip install djangoFor verifying the Django installation, you can check the Django version by
>>>python -m django --versionby this command you can verify whether you have django installed or not by seeing the version on the terminal.
Get C S Job’s stories in your inbox
Join Medium for free to get updates from this writer.
Django have many commands which is useful in the project creation. you can see those by running the following command,
>>>django-adminSome of the commands are as follows,
🌟 For creating a new project
>>>django-admin startproject shop here I used “shop” as my project name. you can use your project name here
Look! some files have been created:
shop/
manage.py
shop/
__init__.py
settings.py
urls.py
asgi.py
wsgi.pyThese files are:
- The outer
shop/root directory is a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like. manage.py: A command-line utility that lets you interact with this Django project in various ways.- The inner
shop/directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g.shop.urls). shop/__init__.py: An empty file that tells Python that this directory should be considered a Python package.shop/settings.py: Settings/configuration for this Django project.shop/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site.shop/asgi.py: An entry-point for ASGI-compatible web servers to serve your project.shop/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project.
🌟For running the project server
>>>python manage.py runserver run the command on terminal and go to browser and check for localhost:8000 , You can see a default django interface there.
You can change the default port number by adding the port number in the end;
python manage.py runserver 9000
These are some of the prerequisite for django.
You can find the complete step by step procedure for creating a basic Django project here ⬅








