Monthly Archives: May 2022

DJANGO ARCHITECTURE

DJANGO INTRODUCTION Before starting to talk about the Django Framework I leave you a link to the official documentation which will come back very useful later. https://docs.djangoproject.com/it/4.0/. The main purpose of this first dedicated section is to provide a good overview of the Framework, and of the main parts that make it up. This will facilitate the understanding of the role played by the individual components, which we will analyze and use in detail in the following sections. WHAT IS DJANGO Django is a high-level Web Framework written in Python, which enables the development of secure and scalable websites [...]

By |2022-10-26T00:41:07+00:00May 18, 2022|0 Comments

FIRST PROJECT IN DJANGO

FIRST PROJECT IN DJANGO VIRTUAL ENVIRONMENTS The first thing we have to do to work on virtual environments is to create a folder, once the created folder has been selected, with the cd command in Windows, or ls in Linux we give the following command: python -m venv virtual_name_environment This command creates the virtual environment with all the files necessary for the project to work, including Python binaries. The following image shows the virtual environment just created in the visual studio code. Once the environment has been created, it must be activated [...]

By |2024-11-11T18:47:34+00:00May 20, 2022|0 Comments

FIRST APPLICATION IN DJANGO

FIRST DJANGO APPLICATION After having created the first project with the command django-admin startproject project_name it is time to analyze the individual files created. WE CREATE OUR FIRST APPLICATION Let's go to visual studio code and create our first application with the above command, positioning ourselves in the directory where the manage.py file is contained. Let's analyze the files that make up a Django application. __init__.py an empty file [...]

By |2024-11-11T18:48:22+00:00May 22, 2022|0 Comments

MODELS AND MIGRATIONS

MODELS AND MIGRATIONS We will see in this post after the creation of a news application, how it is possible to define through classes and OOP entities (classes) that they represent the conceptual model of our App. We will do this by writing the models.py file of our application. Once the conceptual model has been written and its relationships established, we will create the Sqlite database using the migration mechanism. Let's start by creating a new virtual environment, after creating the root folder that I called secondlevel. We issue the following commands to create [...]

By |2024-11-11T18:49:26+00:00May 24, 2022|0 Comments

THE VIEWS IN DJANGO

DATABASE API Before dealing with the views, let's see how to interact further with the database, add data, modify them, delete them, make filters etc. Django provides APIs that allow us to interact with the database at a higher level than SQL (Structure Query Language). LET'S BEGIN! We open our project and in the terminal we type the following command: python manage.py shell This command is used to open a shell where we will type commands. First of all, let's import the Giornalista entity with the following command. from news.models import [...]

By |2024-11-11T18:50:17+00:00May 25, 2022|0 Comments

THE TEMPLATES IN DJANGO

THE TEMPLATES Templates are nothing more than html files set in the views in the render method. The render method accepts three parameters, the request, the html file we want to render and a third parameter, the context which is a data dictionary in which we are going to specify what we want to display in the html page. We will be able to set up the html file so that it displays articoli and giornalisti. We decide where the html file resides, we go to the settings.py file [...]

By |2024-11-11T18:51:01+00:00May 29, 2022|0 Comments

THE URLS IN DJANGO

THE URLS IN DJANGO URLS are used to map the resources of our application, and are fundamental in the Django architecture. We create an urls.py file within the news application and include it in the project's urls.py file. As shown in the image. While the application's urls.py file we modify it as follows: We have seen that the path function is used to map a specific url to a view. In the image above you can see how angle brackets are used to define the detail of [...]

By |2024-11-11T18:51:46+00:00May 29, 2022|0 Comments

STATIC FILES IN DJANGO

STATIC FILES IN DJANGO Static files are images, css, javascript files, fonts etc. in essence we turn to all those components that then represent the front-end part. Django in ready-to-use applications provides us with the django.contrib.staticfiles application that we need static files. Let's go to the settings.py file of the project and scroll the page until we find the STATIC_URL entry. Let's specify the directory that will contain our static files, such as Bootstrap. Now let's create the static folder in BASE_DIR remembering that this constant indicates the folders immediately [...]

By |2024-11-11T18:52:27+00:00May 30, 2022|0 Comments

BOOTSTRAP GET STARTED

BOOTSTRAP 5 GET STARTED Bootstrap is one of the world's most popular front-end development component libraries, open-Source, it was originally developed by Mark Otto and Jacob Thornton at Twitter. Mobile-First: allows us to develop responsive websites, which automatically adapt to the device used. Bootstrap is a free front-end framework for easier and faster web development, includes HTML and CSS based design templates for typography, forms, buttons, tables, navigation, modals, image carousels and many more, as well as plug-ins Optional JavaScript. Bootstrap also gives you the ability to easily create responsive designs. NOTE: When we talk about Bootstrap components, I [...]

By |2024-10-29T03:13:25+00:00May 12, 2022|0 Comments

CONTAINER BOOTSTRAP FIVE

CONTAINER BOOTSTRAP 5 You learned from the previous post that Bootstrap requires a containment element to wrap the site's content. The containers are used to fill the content within them and there are two classes available: The .container class provides a fixed-width responsive container The .container-fluid class provides a full-width container, which spans the full width of the window. CONTAINER FIXED Use the .container class to create a fixed-width responsive container. Note that its width (max-width) will change on different screen sizes: FLUID CONTAINER Use the .container-fluid class to create a full-width container, which will [...]

By |2024-11-11T17:55:20+00:00May 12, 2022|0 Comments
Go to Top