Category: 1. Tutorial

  • Add Master Template

    Django supports template inheritance. The concept of inheritance in Django is very similar to inheritance in object-oriented programming. The idea is that the output rendered by each view in a web application must follow a uniform pattern or look, even though each view may render a different template. Suppose a Django app has three URL…

  • MVT Architecture

    Most of the web frameworks implement the MVC (Model-View-Controller) architecture. Django uses a variation of MVC and calls it the MVT (stands for Model-View-Template) architecture. The Advantage of Using a Web Framework A software framework, in general, is a standard, reusable software platform that facilitates rapid development of software applications. In contrast, a web framework (also called…

  • Template System

    Django makes it possible to separate python and HTML, the python goes in views and HTML goes in templates. To link the two, Django relies on the render function and the Django Template language. The Render Function This function takes three parameters − Django Template Language (DTL) Django’s template engine offers a mini-language to define…

  • Index Page

    When a new Django project is created with the startproject command, the URL http://localhost:8000/ shows a default index page. It shows that the Django installation is done successfully. Create a project with the following command − Now that your project is created and configured, make sure it’s working − On running the above command, you will get to see…

  • URL Mapping

    Now that we have a working view as explained in the previous chapters. We want to access that view via a URL. Django has his own way for URL mapping and it’s done by editing your project url.py file (myproject/url.py). The url.py file looks like − When a user makes a request for a page on…

  • Creating Views

    A view function, or “view” for short, is simply a Python function that takes a web request and returns a web response. This response can be the HTML contents of a Web page, or a redirect, or a 404 error, or an XML document, or an image, etc. Example: You use view to create web…

  • Apps Life Cycle

    A project is a sum of many applications. Every application has an objective and can be reused into another project, like the contact form on a website can be an application, and can be reused for others. See it as a module of your project. Create an Application We assume you are in your project…

  • Creating a Project

    Now that we have installed Django, let’s start using it. In Django, every web app you want to create is called a project; and a project is a sum of applications. An application is a set of code files relying on the MVT pattern. As example let’s say we want to build a website, the…

  • Environment

    Django development environment consists of installing and setting up Python, Django, and a Database System. Since Django deals with web application, it’s worth mentioning that you would need a web server setup as well. Step 1 – Installing Python Django is written in 100% pure Python code, so you’ll need to install Python on your…

  • Overview

    As you already know, Django is a Python web framework. And like most modern framework, Django supports the MVC pattern. First let’s see what is the Model-View-Controller (MVC) pattern, and then we will look at Django’s specificity for the Model-View-Template (MVT) pattern. MVC Pattern When talking about applications that provides UI (web or desktop), we…