The Django way ...

oderofrancis

FRANCIS ODERO

Posted on July 20, 2022

The Django way ...

Django web framework

Django is a web framework written in Python (although it’s not limited to Python) that allows developers to build web applications more easily. It has a great community of users and developers, and it provides over 800 pre-defined actions in a model, and 1300 actions in a view. Django makes it very easy to write web applications that behave like websites, but with much more power, flexibility, and security.

History of Django

Django started as a project developed by a Django web development company: Stuck in Customs. Stuck in Customs CEO, Daniel Gultsch, started the project to make things easier for his team. Once Django was available, Stuck in Customs would submit it to their community to get feedback. Since the team had developed Django, it became easy for them to develop.

The project quickly grew beyond a simple web application framework, and Django’s founders made a website for the Django community. Soon, over 100 people downloaded the framework each day. The number of Django contributors grew, as well. The Django community eventually became a legal entity: the Django Software Foundation.

Django was originally released under the GNU General Public License (GPL). It is now licensed under the Apache License 2.0.

  1. Django is flexible enough to fit any web application.
  2. Django is modern. It’s based on a modern design pattern called “Model-View-Template” (MVT).

Django comes with a built-in web server. So, unlike Django, you don’t need to install Apache, Nginx, or IIS, etc. in order to run Django.

Installing Django

The recommended way to install Django is to use pip. Install it with:

$ pip install django

Or, if you don’t have pip, you can install it with:

$ easy_install django

Installing Django creates a Django project, so you’ll need to create a virtualenv (or run Python with --prefix), and then activate it.

Running Django

Python projects run in a virtualenv by default.

Create a directory and access the directory

mkdir dj

then

cd dj

Create a virtualenv for your project:

$ virtualenv django

Activate the virtualenv:

$ source django/bin/activate

create arequirements.txt file

touch requirements.txt

Install Django in your virtualenv that you created.

pip install django==3.2

Create a django project:

django-admin startproject mysite .

This will create django project in the same folder as we have included a dot at the end .

python manage.py migrate

Then run your project:

$ python manage.py runserver

This will run Django’s built-in web server on port 8000.

You can test your project by visiting http://localhost:8000/.

Django comes with built-in support for SSL. All you have to do is tell Django which certificates to use for the server and clients, and then run:

$ python manage.py runserver -h 0.0.0.0

If you want to connect to your Django project from another computer, either use SSH tunneling or run a local port forward.

Django comes with built-in support for SSL.

Web Pages

Django includes built-in support for templating. And, it’s a lightweight template language, so you can run Django locally without installing anything else.

Templates (or just templates) are files that define how your web page should look. Django comes with two templates: django template.defaults and django.template.loaders.seq. By default, django template.defaults is an alias for django.template.loaders.seq.
This plays an important role in MVT structure as Django framework efficiently handles and generates dynamically HTML web pages that are visible to the end-user.

Thank you for your Time
Let's meet next on the next section of creating Django application.

💖 💪 🙅 🚩
oderofrancis
FRANCIS ODERO

Posted on July 20, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related