En español

What is Django 5 and what is it for or why use it in web development?

Django is an excellent framework and the most famous or at least the first that comes to mind when we talk about web Python; Django offers us from the installation of the framework everything necessary to create small or large projects; Django 5 is a powerful framework whose main advantages are:

  • Creating modular applications
  • Programming in the Python multipurpose programming languag
  • THE ENTIRE Python ecosystem to develop our web apps
  • Multiple packages that we can install through pip and use them in our project, whether for Python or specifically for Django
  • It brings us a complete module or application to perform data management, that is, the famous CRUD
  • Design our own friendly URLs easily
  • An effective approach to maintaining project requirements

We are going to talk about other fundamental features about the framework such as:

Creating a management module quickly, dynamically and personalized with the admin app

A Django project has several applications, one of the most interesting is the application called admin, which comes to us for free when we create a Django project. It has a high level of customization that ranges from defining how to present the different elements of the CRUD, group form elements, as well as define field types, register related forms, organize the table or list, define filters and search fields, change the style and much more to create personalized applications for our clients.

MTV for everything

The structure of a project in Django is based on the MTV pattern that we already talked about in a previous entry, therefore, we have a first-class organization to divide our development into layers or levels.

A complete ORM to manage our database

We have a complete ORM or Object Relational Model, very agile to use and we can create all types of structure and relationships with our database easily and efficiently; Django's ORM, like many other technologies, assigns a model to a table in the database where a column in the database corresponds to a property of the table

Through the models, we can create, read, update and delete records in the database, which can be PostgreSQL, MySQL, Oracle and SQLite.

Migrations to have the structure of our database

It manages a migration system based on model classes that we define to have a one-to-one relationship between the model and the migration.

To create a migration we can do it easily and efficiently, since we can generate it through the command line and the entire Model class of our MTV as source code.

Efficient and accurate command line

It has a simple command line to perform recurring operations in our project that range from managing migrations, creating super users to a simple development web server.

More complete apps and less code

Because we are working in a Python ecosystem, it allows us to extend our app through thousands of components or packages that we can quickly install and configure to provide our application with more features.

We can extend the application in a modular manner for easy reuse of these modular components.

Developed using Python, the current programming language, multifunctional and syntactically friendly and very clean.

Apart from all this, Django is a framework that comes with everything we need to make the most common applications in a versatile and scalable way.

Versatile apps

Django is a framework with which you can build any type of application from our MTV: from Rest Apis, online stores as we do in our course, Blogs and return the content in any format such as HTML, RSS, JSON, etc.

Some of the main features of Django are:

  • Django provides the tools to make most basic applications, to perform common operations such as connecting to the database, user administration, forms, among others.
  • The ORM is the mechanism that we use in this type of frameworks to interact with the database, with this eORM, we can abstract ourselves from creating SQL to connect to the database, if not, use a set of methods to perform these operations, which Best of all, we can easily switch from one database engine to another without needing to change a single line of code.
  • Security: One of the advantages we have of using frameworks is that since they are made up of patterns, they prevent us from making common mistakes, which improves security when programming the application.
  • Scalability: Django can be used to build websites of any size, whether it has millions of visits or not, we can easily scale the application with more modules, installing specific packages for Django or Python that we then use as key pieces at the time of development.

Secure Framework

Django, as with other frameworks such as Laravel or CodeIgniter or Flask itself, is a secure framework; which we owe largely to its MTV layers, but also to the protection of sensitive elements such as passwords by hashing; Thanks to our ORM we can also bypass vulnerabilities based on SQL injection, avoid CSRF attacks and much more.

Scalable

A Django project consists of one or multiple applications, which can share resources easily and securely thanks to the Python ecosystem and again thanks to the separation by layers that the MTV framework itself offers us.

Portable

By being able to run Python on the most famous Operating Systems such as Windows, Linux and MacOS, we can run Django and develop it wherever we want in a simple, configurable and secure way; although, in Windows we may have some peculiarities at the time of development

Installing Django 5

Now, with our Python ready, the next thing we are going to do is install Django, which we can easily install our package manager that we have for free in Python 3:

python -m pip install Django

And with this we can start developing our applications in Django and create the project/application game that we will discuss in a later post, but so as not to leave you on tenterhooks; A project has multiple applications and Django projects have a very peculiar order; Here the first thing you have to understand is how a project is formed in Django, and that is that in a project we can have multiple applications like the one we handle in our Django course:

Proyecto Django

How to get started with Django

Remember that if you are interested in developing in Django, in our Django course that you can take on this platform you can learn this and much more.

You can obtain more information in the official documentation and remember that in the following guides we will see how to use Django to develop our projects.

Let's start by talking about the framework, what it is and the advantages it offers us:

¿Qué es Django 3 framework y para qué usarlo para desarrollar apps web?

Continuar leyendo 

Now with a basic idea of the framework, we talk about MTV, which is the variation of MVC:

El patrón de diseño MTV en Django y su relación con el MVC

Continuar leyendo 

We are going to start creating a basic application, for that the first thing you need to know is how to create a project and application in Django, apart from what each of them is for since they are the key components in any Django project:

Creando nuestro primer proyecto y aplicación (app) en Django

Continuar leyendo 

One of the fundamental differences that we have in Django if we compare it with other frameworks, is the distinction between project and application, which in Django corresponds to a structure and configuration, so, once our project has been created, we create the first application:

Creando nuestro primer ejemplo completo de hola mundo en Django

Continuar leyendo 

Once you have your Django installed on your computer ready, and your project and at least one application generated, the next thing you probably want to do is add your first line of code, your hello world in Django, which is the letter of introduction in any programming language or framework you want to start:

Creando nuestro primer ejemplo completo de hola mundo en Django

Continuar leyendo 

A very important point in Django is that part of the MTV is formed by a routing, which we have to define to connect the URLs to a view in Django, and we can easily do this with a configuration file for this purpose that allows us map all components:

Cargar vistas en archivos de URLs en Django

Continuar leyendo 

Once you know the routes, the next step is to know how to give them a name, this is very useful to reference them later in a very easy way:

Rutas con nombre en Django

Continuar leyendo 

Databases are a fundamental component today that allows us to make all our data persistent and therefore take our Django project to another level; but for that you need to learn how to make this connection to a MySQL database with Django correctly:

Configurar y conectar una base de datos en un proyecto en Django (MySQL)

Continuar leyendo 

Once connected to the database, we need to work with the data layer, which cannot be other than the model, which allows us to connect to a table (already previously created through migrations) in particular to either obtain data, delete it, update it or simply create new records:

Crear migraciones para la base de datos en Django 3

Continuar leyendo 

So at this point we have everything ready, and we can do something more interesting how to create our first views, the simplest views or one of the simplest that we can build would be the lists in Django, to show a set of records; Here we work completely with our MTV, to define the logic to manipulate the data, obtain the data and display it in an HTML template with the help of some Django directives:

Como usar Django con Python: Crea una vista simple de listado

Continuar leyendo 

To interact with the different controllers/views that exist in Django, we do it through the route system, since this is common in this type of framework:

Cargar vistas en archivos de URLs en Django

Continuar leyendo 

With the Django project already started, it is a good idea to know some important Framework commands:

Comandos y configuraciones imprescindibles al momento de crear cualquier aplicación en Django

Continuar leyendo 

Another aspect that we must consider is knowing which entities we are going to create. In Django, like many other frameworks, we do it through the models layer:

Creando modelos en Django

Continuar leyendo

El metodo __str__ en los modelos para imprimir una representación en texto del modelo/clase

Continuar leyendo 

And then, in order to create the tables related to the models in the database, we do it through migrations:

Crear migraciones para la base de datos en Django 5

Continuar leyendo 

The management of forms is essential to carry out almost any operation, it is the format that exists par excellence to obtain user data and be able to create and update records and with this, interact with the data:

¿Qué son, y cómo crear un formulario con Django?

Continuar leyendo

Trabajando con formularios en Django, crear un registro

Continuar leyendo 

Created some records, we can show them in a list:

Paginación de tablas (registros) en Django empleando Bootstrap 4 o 5

Continuar leyendo 

Continuing with the creation of our CRUD, the next operation we are going to perform is to create the detail view:

CRUD en Django, crear la página de detalle o show

Continuar leyendo 

The next operation is to delete the records:

Borrar registros en Django

Continuar leyendo 

Many times we need to create a process that runs before something, for example, always checking that an authenticated user complies with certain rules before accessing different modules, this can be configured using middleware:

Todo sobre los middlewares personalizados en Django

Continuar leyendo 

One of the great features that we have available in Django and that makes a difference with any web system, is Django Admin, from which we can manage our website with very few lines of code:

¿Qué es Django Admin?

Continuar leyendo 

The Rest APIs are fundamental pieces in almost any system, knowing how to create them is a very important step that will help you when we want to expand the application, and even expand it through authentication with Tokens, for all these wonders, we use Django Rest Framework :

Crear una Restful Api (CRUD) empleando Django Rest Framework

Continuar leyendo

Token de autenticación en la Rest Api emplando Django Rest Framework

Continuar leyendo 

Crear una Restful Api (CRUD) empleando Django Rest Framework

Continuar leyendo 

There are many aspects that make Django a very robust framework, which is not only its modularity, great basic functionalities, but also its integration with Python packages or exclusively for Django, such as Channels, to create channels in an asynchronous application:

Websockets en Django empleando Django Channels, Servidores wsgi y asgi

Continuar leyendo 

Course and Book to master Django

If you were left wanting more, I bring you these premium resources at your disposal.

Django is a framework with many options, it allows us to create applications with the current language Python, a modular programming language, with impeccable syntax that we can also use in a web environment.

It offers us a modular scheme between project and applications, an important set of packages to extend the already complete framework and with this, the creation of scalable projects.

It is a framework that, by using Python, brings with it the benefits of a clean, clear, precise syntax, a modular and scalable environment through packages.

In this book, we are going to learn how the framework is formed, the basic characteristics that Django allows us as a framework par excellence to create CRUD processes, which go from the creation of views, templates, connection with models, routing, form validations, creating middleware among others.

In short, you will have enormous material at your disposal to make real web applications.

This book course is aimed at anyone who wants to start developing with Django; You may come from another framework or even PHP; In both cases it is a great idea to learn from one of the most advanced and complete web frameworks you can find.

For those who want to know the framework and who know other web frameworks, but do not have the necessary knowledge to venture into these.

For those people who want to learn something new, learn about a framework that, although it has a lot of documentation, most of it is in English and since the framework is constantly evolving, it tends to become outdated.

For people who want to improve a skill in web development, who want to grow as a developer and who want to continue climbing their path with other frameworks similar to this one.

For those who want to learn or improve a skill and with this, increase their chances of employment or to carry out a personal project.

This guide is intended to take your first steps with Django; With this, we are going to propose two things:

  1. It is not a guide that aims to know Django 100%, or from zero to expert, since it would be too big an objective for the scope of this guide, if not to know its ecosystem, what it offers us and how it works in based on several examples and/or small applications with limited scope.
  2. It is assumed that the reader has at least basic knowledge of the Python programming language, as well as web technologies such as HTML, CSS and JavaScript; It is also recommended that you have at least theoretical knowledge about the framework in the use of modules, migrations, MTV; although in the book we make introductions to the entire base structure of the framework.

Remember that you can consult the list

Ver Listado »

Acepto recibir anuncios de interes sobre este Blog.