<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mattia Giupponi on Medium]]></title>
        <description><![CDATA[Stories by Mattia Giupponi on Medium]]></description>
        <link>https://medium.com/@mattia-giupponi?source=rss-8990286b2a73------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*b1ZNjp8HoK73oU5o</url>
            <title>Stories by Mattia Giupponi on Medium</title>
            <link>https://medium.com/@mattia-giupponi?source=rss-8990286b2a73------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 14:26:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mattia-giupponi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to debug Airflow task with VS Code]]></title>
            <link>https://mattia-giupponi.medium.com/how-to-debug-airflow-task-with-vs-code-54b05c5ee485?source=rss-8990286b2a73------2</link>
            <guid isPermaLink="false">https://medium.com/p/54b05c5ee485</guid>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Mattia Giupponi]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 07:56:24 GMT</pubDate>
            <atom:updated>2023-06-07T07:56:24.535Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s see how we can debug code in our airflow task using VS code</p><figure><img alt="everyday struggle" src="https://cdn-images-1.medium.com/max/1024/0*imLWJ25K7oB3zvup" /><figcaption>Photo by <a href="https://unsplash.com/@zanilic?utm_source=medium&amp;utm_medium=referral">Zan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Airflow is a platform for developing, scheduling, and monitoring batch workflows for those who don&#39;t know it. It has a robust community, which is always appreciated in the open source.<br>Follows some of the main characteristics of Airflow:</p><ul><li><strong>Dynamic</strong>: Airflow pipelines are configured as Python code, allowing for dynamic pipeline generation.</li><li><strong>Extensible</strong>: The Airflow framework contains operators to connect with numerous technologies. All Airflow components are extensible to easily adjust to your environment.</li><li><strong>Flexible</strong>: Workflow parameterization is built-in leveraging the <a href="https://jinja.palletsprojects.com/">Jinja</a> templating engine.</li></ul><p>For those who want to have a deeper knowledge of Airflow, here is the link to the documentation:</p><p><a href="https://airflow.apache.org/docs/apache-airflow/stable/index.html">https://airflow.apache.org/docs/apache-airflow/stable/index.html</a></p><p>As a developer that uses Airflow quite often, in the beginning, I always find it difficult to debug the Python code written in Airflow inside a Task.<br>The expected can say:<br>“<em>You should externalize the function of the task and test them, then if you need to debug you just have to run your unittest and see how it behaves”</em></p><p>Usually yes, that is the right approach, but airflow has its own ecosystem which adds information to the task, and operators and sometimes is hard to replicate.<br><strong>The main focus of this article is to see how we can go with a debugger inside an Airflow task and see what is really doing outside the unittest</strong></p><h3>Let’s write an example DAG</h3><p><em>We assume that the environment is ready with Airflow pre-installed and configured as needed, more info can be found here:<br></em><a href="https://airflow.apache.org/docs/apache-airflow/stable/installation/index.html#using-pypi"><em>https://airflow.apache.org/docs/apache-airflow/stable/installation/index.html#using-pypi</em></a></p><pre>from datetime import datetime<br><br>from airflow import DAG<br>from airflow.decorators import task<br>from airflow.operators.bash import BashOperator<br>from airflow.operators.empty import EmptyOperator<br>from airflow.operators.python import get_current_context<br><br>with DAG(<br>    dag_id=&quot;test_for_medium&quot;,<br>    start_date=datetime(2022, 1, 1),<br>    schedule=None<br>) as dag:<br><br>    hello = EmptyOperator(task_id=&quot;operator&quot;)<br>    empty = EmptyOperator(task_id=&quot;operator&quot;)<br><br>    @task()<br>    def airflow():<br>        from dag_utils.my_package import my_amazing_function<br>    <br>        # take task_instance<br>        dag_context = get_current_context()<br>        ti = dag_context[&#39;ti&#39;]<br>        input_val1 = ti.xcom_pull(&#39;operator&#39;)<br>        input_val2 = ti.xcom_pull(&#39;operator2&#39;)<br>        # here much can be done like:<br>        # - call the DB<br>        # - manage the XCOM to enrich them<br>        <br>        output = my_amazing_function(input_val1, input_val2)<br>        return output<br><br>    hello &gt;&gt; empty &gt;&gt; airflow()</pre><p>The above code represents a simple example of dag where the two task<br> operator2 and operator return some value in the Airflow XCOM<br><strong>NOTE: the empty operator doesn&#39;t return anything, I used it just as an example</strong></p><h3>Let’s configure VS Code</h3><p><em>Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.</em></p><p>VScode has a powerful integrated debug tool that can be used almost for every language and is easily customizable.</p><p>Follows the link with the description of how to configure it on your machine and some hits about how it works:<br><a href="https://code.visualstudio.com/docs/editor/debugging">https://code.visualstudio.com/docs/editor/debugging</a></p><p>Once you read the documentation of the debugging and after the launch.json is available in your environment, open it and paste the following json configuration:</p><pre>{<br>    &quot;version&quot;: &quot;0.2.0&quot;,<br>    &quot;configurations&quot;: [<br>        {<br>            &quot;name&quot;: &quot;Python: example_dag&quot;, // &lt;- name of the session<br>            &quot;type&quot;: &quot;python&quot;,<br>            &quot;request&quot;: &quot;launch&quot;,<br>            &quot;program&quot;: &quot;/home/mattia/miniconda3/envs/my_env/bin/airflow&quot;, // &lt;-- path to the airflow installed in your environment (in mine was under miniconda)<br>            &quot;console&quot;: &quot;integratedTerminal&quot;,<br>            &quot;args&quot;: [<br>                &quot;tasks&quot;, // &lt;-- CLI commands<br>                &quot;test&quot;, // &lt;-- CLI commands<br>                &quot;test_for_medium&quot;, // &lt;-- dag_id<br>                &quot;airflow&quot;, // &lt;-- task_name to be debugged<br>                &quot;2023-05-26T13:34:55Z&quot; // &lt;-- an execution date<br>            ],<br>            &quot;justMyCode&quot;: false, // &lt;--- if FALSE the debugger will work even in the code which you didnt wrote, useful if you want to debug the airlfow behavior too<br>        },<br>    ]<br>}</pre><p>After running the debugger in VS code we can see that our break-point is used and we are not able to debug the code directly in Airflow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*SAvJZZRyLr3m-98dJLc8Gw.png" /></figure><p>In this article, we cover how to debug an Airflow task using VS code.<br>In the above example, only PythonOperator were used, but this can be done also with your own custom operator in their execute method</p><p>If you want more articles about Airflow, comment on this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54b05c5ee485" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced installation of GeoNode on Ubuntu]]></title>
            <link>https://mattia-giupponi.medium.com/advanced-installation-of-geonode-on-ubuntu-a00dbbc23532?source=rss-8990286b2a73------2</link>
            <guid isPermaLink="false">https://medium.com/p/a00dbbc23532</guid>
            <category><![CDATA[geonode]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Mattia Giupponi]]></dc:creator>
            <pubDate>Sat, 18 Sep 2021 13:21:46 GMT</pubDate>
            <atom:updated>2021-09-21T15:57:41.574Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s find an easy way to install GeoNode on our local machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8HVLeRq42NNtFs_3" /><figcaption>Photo by <a href="https://unsplash.com/@dead____artist?utm_source=medium&amp;utm_medium=referral">Capturing the human heart.</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For those who don&#39;t know, GeoNode is an <a href="https://en.wikipedia.org/wiki/Open_source">Open Source</a> Geospatial content management system (written in Django) designed to be extendible and modifiable.</p><p>From the official <a href="https://geonode.org/">website</a>, GeoNode is described as follow:</p><blockquote>GeoNode is a web-based application and platform for developing geospatial information systems (GIS) and for deploying spatial data infrastructures (SDI). It is designed to be extended and modified, and can be integrated into existing platforms.</blockquote><p>Now that we have an overview of what GeoNode is, let’s start with the installation.</p><h3><strong>Prerequisites:</strong></h3><p>Before starting, make sure that you have the following programs installed on your machine:</p><ul><li>Python ≥ 3.7 and VirtualEnv or MiniConda</li><li>Java OpenJDK (in this tutorial for example I have the v11.0.11)</li><li>vim or nano</li><li>git</li></ul><h3><strong>Step 1: update ubuntu environment</strong></h3><p>As usual, it’s always better to update our ubuntu environment and add the ubuntugispackage to our repositories. So open a command line and run the following commands:</p><pre>sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable<br>sudo apt update -y; sudo apt upgrade -y;</pre><h3><strong>Step 2: Install the dependencies</strong></h3><p>GeoNode requires different dependencies (special the GDAL ones) so it’s required to install them by running:</p><pre>sudo apt install -y build-essential gdal-bin <strong>\</strong><br>    libxml2 libxml2-dev gettext <strong>\</strong><br>    libxslt1-dev libjpeg-dev libpng-dev libpq-dev libgdal-dev <strong>\</strong><br>    software-properties-common build-essential <strong>\</strong><br>    git unzip gcc zlib1g-dev libgeos-dev libproj-dev</pre><h3><strong>Step 3: clone GeoNode repository</strong></h3><p>In this tutorial, we will take into consideration GeoNode <em>master</em>, but you can clone the version that you prefer.</p><p>So let’s create a folder where we want to clone the repository and use the following command:</p><pre>➜ mkdir /home/mattia/tutorials <br>➜ cd /home/mattia/tutorials<br>➜  git clone <a href="https://github.com/GeoNode/geonode.git">https://github.com/GeoNode/geonode.git</a></pre><h3><strong>Step 4: Install GeoNode requirements</strong></h3><p>Now we need to create a virtual environment for our project, I’m using virtualenvwrapper</p><pre>➜ source /usr/share/virtualenvwrapper/virtualenvwrapper.sh<br>➜ mkvirtualenv — python=/usr/bin/python3.8 medium_tutorial<br>(medium_tutorial) ➜</pre><p>As you can see now we have a fresh new environment ready to be used to install our requirements.</p><p><em>NOTE: in case the virtualenvwrapper raise some issue, remember to export the </em><em>WORKON_HOME=~/.virtualenvs</em></p><p>Now proceed to install all the dependencies required:</p><pre>➜ cd geonode<br>➜ pip install -r requirements.txt --upgrade --no-cache-dir<br>➜ pip install -e . --upgrade<br>➜ pip install pygdal==&quot;`gdal-config --version`.*&quot;</pre><h3>Step 5: Install Postgres &amp; PostGIS</h3><p>GeoNode requires a database to run with the GIS extension. Since Spatialite is not supported, we will use Postgres (which for sure is much better for a production environment than SQLite!)</p><p>To install it, run the following command:</p><pre>➜ sudo apt update -y; sudo apt install -y postgresql-13 postgresql-13-postgis-3 postgresql-13-postgis-3-scripts postgresql-13 postgresql-client-13</pre><p>After the installation we need to run up the service and create the geonode user:</p><pre>➜ sudo service postgresql start<br>➜ sudo -u postgres createuser -P geonode (use geonode as password)</pre><p>Once the user is available, the next step consists of the creation of two databases named geonode and geonode_data with the PostGIS extension:</p><pre>➜ sudo -u postgres createdb geonode<br>➜ sudo -u postgres psql -d geonode -c ‘CREATE EXTENSION postgis;’<br>➜ sudo -u postgres psql -d geonode -c ‘GRANT ALL ON geometry_columns TO PUBLIC;’<br>➜ sudo -u postgres psql -d geonode -c ‘GRANT ALL ON spatial_ref_sys TO PUBLIC;’<br>➜ sudo -u postgres psql -d geonode -c ‘GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO geonode;’</pre><pre>➜ sudo -u postgres createdb geonode_data<br>➜ sudo -u postgres psql -d geonode_data -c ‘CREATE EXTENSION postgis;’<br>➜ sudo -u postgres psql -d geonode_data -c ‘GRANT ALL ON geometry_columns TO PUBLIC;’<br>➜ sudo -u postgres psql -d geonode_data -c ‘GRANT ALL ON spatial_ref_sys TO PUBLIC;’<br>➜ sudo -u postgres psql -d geonode_data -c ‘GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO geonode;’</pre><p>Once the previous steps are done, restart the Postgres service.</p><h3>Step 6: Install GeoServer</h3><p>GeoNode requires that <a href="http://geoserver.org/">GeoServer</a> is installed and running to work.<br>Please refer to GeoServer doc to make it run here is the link:<br><a href="https://docs.geoserver.org/latest/en/user/installation/linux.html">GeoServer installation</a></p><h3>Step 7: Initialize GeoNode</h3><p>Ok, now we should have:</p><ul><li>GeoServer up and running</li><li>Postgres with Postgis installed up and running</li></ul><p>So we can proceed with the migration , we should first export the environment variables with the development configuration and then run the migration:</p><pre>➜ set -a<br>➜ . ./.env_dev<br>➜ set +a<br>➜ python manage.py migrate</pre><p>It will take few seconds to apply all the migrations, after that is needed to import some basic fixtures. The required fixtures are:<br>- sample_admin.json which contains the basic admin user<br>- default_oauth_apps.json which contains the oauth2 auth code for the admin user<br>- initial_data.json which contains groups, categories required</p><p>To load them is enough to use the loaddata Django command:</p><pre>➜ python manage.py loaddata /home/mattia/geonode/people/fixtures/sample_admin.json<br>➜ python manage.py loaddata /home/mattia/geonode/base/fixtures/default_oauth_apps.json<br>➜ python manage.py loaddata /home/mattia/geonode/base/fixtures/initial_data.json</pre><p>NOTE: be sure to change the root of the path based on your GeoNode location.</p><h3>Step 8: Let it runs</h3><p>If all the previous steps are successful, we can finally run GeoNode and since is a Django application is enough to use:</p><pre>➜ python manage.py runserver</pre><p>After some seconds, the application will be up and running at <a href="http://localhost:8000/">http://localhost:8000</a></p><h3>Some Tips</h3><p>I work regularly with GeoNode, so here are some tips that can help you with your daily work with GeoNode:</p><ul><li>Don’t be afraid to go deeper with the official GeoNode documentation. It contains a lot of useful information about the configuration and uses cases</li><li>If you don’t want to invest too much time in this configuration, a docker-compose is available to make the whole set be used, but if you reading this, you are probably more interested in low-level configuration than docker!</li><li>I use VScode when I need to work on it, here is the launch.json file that I use to run it:</li></ul><pre>{<br>    &quot;name&quot;: &quot;Python: local runserver&quot;,<br>    &quot;type&quot;: &quot;python&quot;,<br>    &quot;request&quot;: &quot;launch&quot;,<br>    &quot;program&quot;: &quot;${workspaceFolder}/manage.py&quot;,<br>    &quot;cwd&quot;: &quot;${workspaceFolder}&quot;,<br>    &quot;args&quot;: [<br>        &quot;runserver&quot;<br>    ],<br>    &quot;justMyCode&quot;: false,<br>    &quot;envFile&quot;: &quot;${workspaceFolder}/.env_dev&quot;,<br>    &quot;django&quot;: true<br>}</pre><p>Useful links:</p><p>GeoNode official documentation: <a href="https://docs.geonode.org/en/master/index.html">link</a><br>GeoServer official documentation: <a href="https://docs.geoserver.org/">link</a><br>GeoNode GitHub repository: <a href="https://github.com/GeoNode/geonode">link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a00dbbc23532" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parte 3: Models — La tua prima applicazione in Django]]></title>
            <link>https://mattia-giupponi.medium.com/parte-3-models-la-tua-prima-applicazione-in-django-f76d90b41128?source=rss-8990286b2a73------2</link>
            <guid isPermaLink="false">https://medium.com/p/f76d90b41128</guid>
            <category><![CDATA[italian-developer]]></category>
            <category><![CDATA[italiano]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mattia Giupponi]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 14:25:09 GMT</pubDate>
            <atom:updated>2021-04-25T14:25:09.676Z</atom:updated>
            <content:encoded><![CDATA[<h3>Parte 3: Models — La tua prima applicazione in Django</h3><h4>Cosa sono e come integrarli nel pannello di amministrazione</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*encwdCLKdGM0RyI9" /><figcaption>Photo by <a href="https://unsplash.com/@austindistel?utm_source=medium&amp;utm_medium=referral">Austin Distel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In questo articolo andremo a scoprire cosa sono i Models in Django, cosa rappresentano, come crearli e come integrarli nel pannello di amministrazione.</p><p>Vi lascio il link alla <a href="https://docs.djangoproject.com/en/3.2/topics/db/models/">documentazione</a> ma intanto partiamo subito dalla teoria, per models in Django si intende:</p><p><em>Oggetti che definiscono la struttura dati che andrà memorizzata nel database con i suoi campi (inclusi i tipi). La tipologia del database è ininfluente sulla creazione del Models, infatti ci penserà django tramite il suo </em><a href="https://it.wikipedia.org/wiki/Object-relational_mapping#:~:text=In%20informatica%20l&#39;Object%2DRelational,agli%20oggetti%20con%20sistemi%20RDBMS."><em>ORM</em></a><em> a tradurre il codice in query SQL.</em></p><p>Ora che sappiamo cos’è un models, come lo definiamo?<br>In django tutti i modelli, devono essere sottoclassi della classe <a href="https://docs.djangoproject.com/en/3.2/ref/models/instances/#django.db.models.Model">Model</a>, intanto creiamo il model per il nostro blog. <br>Sicuramente nel nostro blog ci saranno degli articoli perciò iniziamo a definire un model chiamato Articolo con alcune informazioni che ci potranno essere utili, spostiamoci su blog/models.py e usiamo il codice sottostate:</p><pre>class Articolo(models.Model):</pre><pre>    def __str__(self):<br>        return self.titolo </pre><pre>    titolo = models.CharField(max_length=150)<br>    corpo = models.TextField()<br>    preview = models.CharField(max_length=150)<br>    autore = models.ForeignKey(User, on_delete=SET_NULL, null=True)<br>    categoria = models.CharField(max_length=150)<br>    <br>    class Meta:<br>        verbose_name_plural = &quot;Articoli&quot;</pre><p><em>titolo: titolo dell’articolo che pubblicheremo<br>corpo: l’articolo<br>preview: un anticipazione dell’articolo, descrivendo in poche parole di cosa tratterà l’articolo<br>autore: chi ha scritto l’articolo<br>categoria: a che categoria appartiene l’articolo</em></p><p>Come vedere autore non è definito come gli altri campi. Infatti è una ForeignKey la quale connette l’articolo al Modello degli utenti definito di base da django così essere in grado di legare facilmente un articolo al suo autore.</p><p>Una volta creato il modello, è necessario creare la tabella nel database. Per farlo servirà fare 2 passaggi: makemigrations e migrate .</p><p>Makemigrations:</p><p>Questo comando serve per dare la possibilità a django di creare un file di migrazione, il quale conterrà informazioni riguardanti la creazione del modello e delle sue caratteristiche. Oltre alla creazione, qualora volessimo cambiare qualche informazione, sarà necessario rilanciare il comando per dare la possibilità al sistema di creare un nuovo file di migrazione.<br>Le migrazioni in poche parole, contengono la storia delle modifiche fatte ad un modello e di conseguenza al database.</p><p>Di seguito troverete il comando da lanciare i la conferma che è stato creato un file 0001_initial.py e la descrizione di cosa c’è al suo interno</p><pre>python manage.py makemigrations</pre><pre>Migrations for &#39;blog&#39;:<br>  blog/migrations/0001_initial.py<br>    - Create model Articolo</pre><p>Migrate:</p><p>Il comando di migrate, serve per far applicare le modifiche al database. Per farlo basterà:</p><pre>python manage.py migrate</pre><pre>Operations to perform:<br>  Apply all migrations: admin, auth, blog, contenttypes, sessions<br>Running migrations:<br>  Applying blog.0001_initial... OK</pre><p>Una volta termiante le migrazioni con esisto positivo (ok finale), possiamo continuare e registrare il nostro modello nel pannello di amministrazione.</p><p>Apriamo il file blog/admin.py e incolliamo il seguente codice:</p><pre>from django.contrib import admin<br>from tutorial.blog.models import Articolo</pre><pre>class ArticoloAdmin(admin.ModelAdmin):<br>    pass<br>admin.site.register(Articolo, ArticoloAdmin)</pre><p>Cos’è ArticoloAdmin?<br>E’ la rappresentazione del nostro modello all’interno dell’interfaccia di amministrazione. Django ci da la possibilità di decidere cosa far visualizzare nel pannello di amministrazione definendo campi dentro ArticoloAdmin .</p><p>Poniamo il fatto di avere un capo visualizzazioni nel nostro model Articolo.<br>Potenzialmente questo numero, è definito in base alle visualizzazioni dell’articolo e non può e non deve essere modificabile manualmente. Di conseguenza potremmo escludere questo campo dalla visualizzazione, ma di questo parleremo più avanti!</p><p>Una volta registrato il modello, possiamo vedere cos’è successo nel pannello di amministrazione. Quindi avviamo il server di sviluppo usando python manage.py runserver e andiamo sul nostro host locale: <a href="http://localhost:8000/admin/">http://localhost:8000/admin/</a> ed effettuiamo il login:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*IfE1DUSKS_DayvXNuyhQyQ.png" /><figcaption>Pannello di amministrazione</figcaption></figure><p>Come vedete, è apparso il nostro model Articolo sotto la nostra app Blog .</p><p>Ora inseriamo un articolo, basterà cliccare su Add e compilare le informazioni che abbiamo specificato prima nel modello e poi cliccare Save</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*1P0soyi9ezgWBi4HI62FCQ.png" /><figcaption>Esempio compilazione articolo</figcaption></figure><p>Facile no?<br>Ora dobbiamo inserire il nostro articolo nella Homepage così da iniziare a mostrare i nostri articoli sul nostro sito.</p><p>Per farlo, riapriamo view.py e usando ORM di Django, andiamo a recuperare tutti gli articoli che abbiamo nel nostro database e passarli al <em>CONTEXT (dizionario contenente il contesto da passare al template)</em></p><pre>from blog.models import Articolo<br>from django.shortcuts import render</pre><pre>def index(request):<br>    articoli = Articolo.objects.all()<br>    context = {&quot;name&quot;: &quot;Primo blog con django&quot;, &quot;articoli&quot;: articoli}<br>    return render(request, &quot;index.html&quot;, context)</pre><p>Ora modifichiamo il nostro template in modo tale che visualizzi i nostri Articoli. Modifichiamo il tagmaindel file templates/index.html come segue:</p><pre>&lt;main role=&quot;main&quot; class=&quot;flex-shrink-0&quot;&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    &lt;h1 class=&quot;mt-5&quot;&gt;{{name}}&lt;/h1&gt;<br>    {% for articolo in articoli %}<br>    &lt;div class=&quot;row&quot;&gt;<br>        &lt;div class=&quot;col p-4 d-flex flex-column position-static&quot;&gt;<br>          &lt;strong class=&quot;d-inline-block mb-2 text-primary&quot;&gt;{{ articolo.categoria }}&lt;/strong&gt;<br>          &lt;h3 class=&quot;mb-0&quot;&gt;{{ articolo.titolo }}&lt;/h3&gt;<br>          &lt;p class=&quot;card-text mb-auto&quot;&gt;{{articolo.preview}}&lt;/p&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;stretched-link&quot;&gt;continua a leggere&lt;/a&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    {% endfor %}<br>  &lt;/div&gt;<br>&lt;/main&gt;</pre><p>In poche parole, andremo a ciclare sulla variabile articoli creando un HTML per ogni articolo presente, Otterremo un risultato simile a questo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8RNE80s9Y8cAmBtXvmogA.png" /><figcaption>La nostra home dopo aver inserito 3 articoli</figcaption></figure><p>Nel prossimo articolo, vedremo come creare la pagina di dettaglio del nostro articolo, intanto sbizzarritevi modificando il modello, andando ad aggiungere altre informazioni, come ad esempio la data di pubblicazione!</p><p>A presto!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f76d90b41128" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[La tua prima applicazione in Django — part 2]]></title>
            <link>https://mattia-giupponi.medium.com/la-tua-prima-applicazione-in-django-part-2-a0fca9ee0322?source=rss-8990286b2a73------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0fca9ee0322</guid>
            <category><![CDATA[italian-developer]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[sviluppatori]]></category>
            <category><![CDATA[italiano]]></category>
            <dc:creator><![CDATA[Mattia Giupponi]]></dc:creator>
            <pubDate>Sun, 04 Apr 2021 16:45:36 GMT</pubDate>
            <atom:updated>2021-04-04T16:51:32.499Z</atom:updated>
            <content:encoded><![CDATA[<h3>La tua prima applicazione in Django — part 2</h3><h4>Creiamo la nostra prima pagina</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*myw3-Oy_kVlNw2A5" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Nel <a href="https://mattia-giupponi.medium.com/la-tua-prima-applicazione-in-django-e99f6e0839a4">primo articolo</a> abbiamo visto come creare la struttura del nostro primo progetto Django.</p><p>In questo articolo, vedremo in maniera molto semplice come iniziare a creare le nostre pagine personalizzate.</p><p>Entreranno a far parte 2 principi fondamentali:</p><ul><li><a href="https://docs.djangoproject.com/en/3.1/topics/http/views/">view</a>: logica</li><li><a href="https://docs.djangoproject.com/en/3.1/topics/http/urls/">urls</a>: instradamento delle richieste</li></ul><p>Iniziamo con degli esempi concreti per creare la nostra pagina di Index.</p><p>Apriamo il file urls.py nella folder tutorial e vedremo che è strutturato nel seguente modo:</p><pre>from django.contrib import admin<br>from django.urls import path</pre><pre>urlpatterns = [<br>    path(&#39;admin/&#39;, admin.site.urls),<br>]</pre><p>Ora, dobbiamo includere il set di <em>url </em>della nostra applicazione blog all’interno del file <em>url</em> generale del progetto. Questo permetterà a Django di riuscire a vedere le URL della nostra app e di inoltrare correttamente le richieste.</p><p>Per aggiungere le <em>url</em>, dobbiamo utilizzare la funzione include del package django.url :</p><pre>from django.contrib import admin<br>from django.urls import path, include</pre><pre>urlpatterns = [<br>    path(&#39;admin/&#39;, admin.site.urls),<br>    path(&#39;&#39;, include(&#39;blog.urls&#39;))<br>]</pre><p>NOTA: il fatto che il path &#39;&#39; rimandi sempre alla nostra applicazione è voluto ai fini del tutorial</p><p>Ora che abbiamo registrato le URL della nostra app, dobbiamo creare un file all’interno dell’applicazione blog il quale darà un ulteriore livello di specificità per continuare l’inoltramento delle richieste.</p><p>Spostiamoci all’interno della cartella blog e creiamo il file urls.py , una volta creato, avremo una struttura nella cartella simile a questa:</p><pre>blog.<br>├── __init__.py<br>├── __pycache__<br>│ └── __init__.cpython-38.pyc<br>├── admin.py<br>├── apps.py<br>├── migrations<br>│ └── __init__.py<br>├── models.py<br>├── tests.py<br>├── <strong>urls.py</strong><br>└── views.py</pre><p>Apriamo il file e iniziamo ad incollare la prima URL che andrà a mostrare il nostro index:</p><pre>from django.urls import path<br>from . import views</pre><pre>urlpatterns = [<br>    path(&#39;&#39;, views.index, name=&#39;index&#39;),<br>]</pre><p>Fatto ciò andiamo a definire in views.py la logica della nostra funzione index . Apriamo il file e inseriamo il seguente codice:</p><pre>def index(request):<br>    return HttpResponse(&quot;Ciao, benvenuto nel tuo index!&quot;)</pre><p>Di base, le <em>view </em>necessitano di un parametro che è l’oggetto della richiesta, nel quale ci sono diverse informazioni fra cui: utente, tipologia di richiesta, query params, payload ecc…</p><p>Ora che abbiamo creato la nostra pagina view per il nostro index, salviamo e avviamo il server di sviluppo. Per farlo è necessario trovarsi al livello della cartella <em>blog </em>e lanciamo il comando runserver :</p><pre>➜ python manage.py runserver</pre><p>Andiamo sul nostro url locale <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a> e vedremo che rispetto al primo avvio, vedremo la nostra scritta “Ciao, benvenuto nel tuo index!”</p><p>Lo so lo so, è bruttina come pagina, perciò rendiamola un pochino più piacevole.</p><p>Dato che internet è pieno di risorse e di toolkit straordinari, utilizziamone uno estremamente conosciuto cioè <a href="https://getbootstrap.com/">Bootstrap</a>.</p><p>Bootstrap ci mette a disposizione una quantità infinita di opzioni fra CSS e javascript per rendere unico il nostro sito.</p><p>Oltre a questo, ci da anche a disposizione degli esempi già pronti per accelerare la creazione della nostra pagina.</p><p>Prima di iniziare sarà necessario gestire le configurazione dei file statici (es immagini, css, javascript ecc..). A questo <a href="https://docs.djangoproject.com/en/3.1/howto/static-files/">link</a>, troverete tutta la documentazione messa a dispozione da django.</p><p>Apriamo il file settings.py e assicuriamoci che fa la lista delle INSTALLED_APPS sia presente anche django.contrib.staticfiles e che la nostra app sia correttamente registrata nei settings sempre sotto la lista INSTALLED_APPS:</p><pre>INSTALLED_APPS = [<br>    &#39;blog&#39;, &lt;-- la nostra app<br>    &#39;django.contrib.admin&#39;,<br>    &#39;django.contrib.auth&#39;,<br>    &#39;django.contrib.contenttypes&#39;,<br>    &#39;django.contrib.sessions&#39;,<br>    &#39;django.contrib.messages&#39;,<br>    &#39;django.contrib.staticfiles&#39;, &lt;-- app di django<br>]</pre><p>Successivamente dobbiamo definire 3 configurazioni necessarie, perciò aggiungete il codice seguente nel file settings.py :</p><pre>STATIC_URL = &quot;/static/&quot;<br>STATICFILES_DIRS = [<br>    BASE_DIR / &quot;static&quot;,<br>    &quot;/var/www/static/&quot;,<br>]<br>STATIC_ROOT = &quot;/var/www/example.com/static/&quot;</pre><p>Vediamole nel dettaglio:</p><p><strong><em>STATIC_URL</em></strong>: è l’url per il quale verranno chiamati i file statici<br><strong><em>STATICFILES_DIRS</em></strong>: lista delle folder nelle quali django si aspetta di trovare i file statici. L’ordine è importante, verrà utilizzato come file statico la prima occorrenza trovata<br><strong><em>STATIC_ROOT</em></strong>: Variabile necessaria al momento del deploy e della messa in produzione della nostra applicazione.</p><p>Ora all’interno della nostra applicazione, creiamo 2 cartelle diverse static e templates . All’interno di <em>static</em>, salveremo i javascript, css mentre in <em>templates </em>salveremo gli HTML delle nostre pagine.</p><p>Iniziamo a scaricare da bootstrap il nostro esempio, per fare ciò andiamo sul sito di <a href="https://getbootstrap.com/docs/4.5/examples/">bootstrap</a>, scarichiamo il pacchetto con tutti i template e copiamo il file index.html della cartella <strong>sticky-footer-navbar </strong>all’interno della nostra folder template mentre il sticky-footer-navbar.css nella cartella <em>static/css</em></p><p>Dopo aver fatto ciò, dobbiamo modificare anche la nostra <em>view </em>rendendola pronta per poterci mostrare i nostri. Riapriamo il file view.py della app blog e cambiamola come segue:</p><pre>from django.shortcuts import render</pre><pre>def index(request):<br>    contex = {&quot;name&quot;: &quot;Primo blog con django&quot;}<br>    return render(request, &#39;index.html&#39;, context)</pre><p>Abbiamo sostituito la funzione HttpResonse con render . La funzione <em>render</em>, ci permette di caricare un file html e di mostrarlo sul nostro sito. Il <em>context </em>invece, è un dizionario con una serie di chiavi che possono essere passare al template per essere mostrate. Come esempio, ho messo il nome del blog, successivamente vedremo come il <em>context</em> <strong>diventerà fondamentale</strong> per la nostra app.</p><p>Se aggiorniamo il sito vedremo una cosa simile a questa:</p><figure><img alt="index senza JS e CSS" src="https://cdn-images-1.medium.com/max/1024/1*D_w1OGy7A7mPfNhC1SgN4A.png" /><figcaption>Index senza JS e CSS</figcaption></figure><p>Non bella vero? Ora dobbiamo scaricare sempre da bootstrap CSS e Javascript dalla pagina principale del sito e copiamoli nella nostra cartella static . Alla fine la nostra cartella static, apparirà così:</p><pre>.<br>├── css<br>│   ├── bootstrap-grid.css<br>│   ├── bootstrap-grid.css.map<br>│   ├── bootstrap-grid.min.css<br>│   ├── bootstrap-grid.min.css.map<br>│   ├── bootstrap-reboot.css<br>│   ├── bootstrap-reboot.css.map<br>│   ├── bootstrap-reboot.min.css<br>│   ├── bootstrap-reboot.min.css.map<br>│   ├── bootstrap.css<br>│   ├── bootstrap.css.map<br>│   ├── bootstrap.min.css<br>│   ├── bootstrap.min.css.map<br>│   └── sticky-footer-navbar.css<br>└── js<br>    ├── bootstrap.bundle.js<br>    ├── bootstrap.bundle.js.map<br>    ├── bootstrap.bundle.min.js<br>    ├── bootstrap.bundle.min.js.map<br>    ├── bootstrap.js<br>    ├── bootstrap.js.map<br>    ├── bootstrap.min.js<br>    └── bootstrap.min.js.map</pre><p>Ora dobbiamo integrare gli static nel template index.html che abbiamo creato poco fa.</p><p>Come prima cosa dobbiamo dire a Django che in quel HTML dovrà effettivamente caricare dei file statici, perciò subito alla riga 1 mettiamo questo codice {% load static %} .</p><p>Ora dobbiamo sistemare le URL facendo prendere i file CSS e JS.<br>di conseguenza cambiamo tutte le URL cambiando gli href dei CSS aggiungendo il tag per fare in modo che django sia in grado di caricare i file statici.</p><p>Ad esempio l’importazione del file css bootstrap.min.css cambierà come</p><pre>Prima:<br>&lt;link href=&quot;../assets/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;</pre><pre>Dopo:<br>&lt;link href=&quot;{% <strong>static</strong> &#39;css/bootstrap.min.css&#39; %}&quot; rel=&quot;stylesheet&quot;&gt;</pre><p>aggiungendo il tag <strong>static, </strong>django generarà automaticamente URL necessaria per importare il file. Una volta cambiati tutti gli href e src, andiamo ad aggiornare il nostro index e vedremo che ora la pagina si vede perfettamente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PaleNlGJ6LbjtbmvN0jexA.png" /><figcaption>Index aggiornato con css e js</figcaption></figure><p>Come ultimo passo, aggiorniamo il nome del blog utilizzando la variaible context che abbiamo visto poco prima.</p><p>Riapriamo index.html e sostituiamo la frase “Stiky footer with fixed navbar” con {{ name }} . Se aggiorniamo la pagina, vedremo l’aggiornamento applicato correttamente</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjzbX5HP2L41yqto4F3zpg.png" /><figcaption>template aggiornato con la variabile name del context</figcaption></figure><p>A questo link:</p><p><a href="https://github.com/mattiagiupponi/django-tutorial/tree/part2">https://github.com/mattiagiupponi/django-tutorial/tree/part2</a></p><p>Troverete il codice usato per questo tutorial.</p><p>Nel prossimo articolo, vedremo come costruire un nuovo model e come integrarlo nella nostra pagina e nel pannello di amministrazione!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0fca9ee0322" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[La tua prima applicazione in Django]]></title>
            <link>https://mattia-giupponi.medium.com/la-tua-prima-applicazione-in-django-e99f6e0839a4?source=rss-8990286b2a73------2</link>
            <guid isPermaLink="false">https://medium.com/p/e99f6e0839a4</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[italy]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[sviluppo-software]]></category>
            <category><![CDATA[italiano]]></category>
            <dc:creator><![CDATA[Mattia Giupponi]]></dc:creator>
            <pubDate>Sat, 27 Mar 2021 16:10:32 GMT</pubDate>
            <atom:updated>2021-04-04T14:57:26.338Z</atom:updated>
            <content:encoded><![CDATA[<h3>La tua prima applicazione in Django — part 1</h3><h4>Passo dopo passo, il primo avvio di una piccola applicazione con uno dei framework python più diffusi</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qun9e5jEuCtD7s0D" /><figcaption>Photo by <a href="https://unsplash.com/@faisaldada?utm_source=medium&amp;utm_medium=referral">Faisal</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Nel mondo dell’IT, la maggior parte delle risorse online, di documentazione sono scritte in inglese.</p><p>Almeno a me è capitato in passato, specialmente agli inizi della mia carriera da software developer, di preferire tutorial in italiano rispetto a quelli in inglese.</p><p>L’idea di questa serie di articoli è quella di creare un tutorial in italiano dove passo dopo passo andremo a creare la nostra applicazione in Django.</p><p>Cosa ci servirà?</p><ul><li>Python 3.8</li><li>tanta buona volontà</li><li>IDE (vscode o pycharm)</li></ul><p>In questo tutorial, viene dato per scontato che sulla vostra macchina, sia già installato Python e che abbiate un po di dimestichezza con il terminale.</p><p>Questo <a href="https://docs.microsoft.com/it-it/windows/python/beginners">articolo</a> spiega in maniera esauriente come installare python3 su windows, mentre a questo <a href="https://book.huihoo.com/dive-into-python/2.0_it/html/installing_python/macosx.html">link</a> troverete i passi per MacOS. Se usate linux, non avete bisogno di link, sapere cosa fare!</p><p>In questo tutorial, userò il sub-ambiente linux disponibile su windows. A questo <a href="https://docs.microsoft.com/it-it/windows/wsl/install-win10">link </a>troverete maggiori informazioni su come configurarlo.</p><h3>Step 1: installare Django</h3><p>Una volta installato Python3, possiamo iniziare con il crearci il nostro ambiente virtuale.</p><pre>➜ source /usr/share/virtualenvwrapper/virtualenvwrapper.sh<br>➜ mkvirtualenv — python=/usr/bin/python3 django-tutorial</pre><p>Una volta create, vedrete a sinistra del terminale fra parentesi, la conferma che siamo nella nostra environment virtuale</p><pre>(django-tutorial) ➜  git:(main)</pre><p>Ora possiamo procedere con l’installazione di django. Per farlo basta eseguire il seguente comando:</p><pre>➜ pip install Django</pre><h3>Step 2: Creare il progetto Django</h3><p>Django si divide in 2 concetti,</p><ol><li><strong>Project </strong>: è il progetto, cioè una collezione di settaggi (fra cui quelli del db) necessari per far funzionare l’istanza di django</li><li><strong>App: </strong>per app invece si intende un pacchetto Python che segue delle regole specifiche. Di base il comando di creazione delle app, fornisce una struttura standard.</li></ol><p>Creiamo il nostro project:</p><pre>➜ django-admin startproject tutorial</pre><p>Verrà creata la struttura che segue:</p><pre>tutorial<br>├── manage.py<br>└── tutorial<br>    ├── __init__.py<br>    ├── asgi.py<br>    ├── settings.py<br>    ├── urls.py<br>    └── wsgi.py</pre><p>Ora creiamo la nostra app:</p><pre>➜ cd tutorial<br>➜ django-admin startapp blog</pre><p>Ora avremo la struttura che segue:</p><pre>.<br>└── tutorial<br>    ├── blog<br>    │   ├── __init__.py<br>    │   ├── admin.py<br>    │   ├── apps.py<br>    │   ├── migrations<br>    │   │   └── __init__.py<br>    │   ├── models.py<br>    │   ├── tests.py<br>    │   └── views.py<br>    ├── manage.py<br>    └── tutorial<br>        ├── __init__.py<br>        ├── asgi.py<br>        ├── settings.py<br>        ├── urls.py<br>        └── wsgi.py</pre><h3>Step 3: server di sviluppo</h3><p>Ora che abbiamo creato la nostra struttura, possiamo provare ad avviare il server di sviluppo.<br>Per farlo basta eseguire il seguente comando:</p><pre>➜ cd tutorial<br>➜ python manage.py runserver</pre><pre>Watching for file changes with StatReloader<br>Performing system checks...</pre><pre>System check identified no issues (0 silenced).</pre><pre>You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.<br>Run &#39;python manage.py migrate&#39; to apply them.<br>March 27, 2021 - 15:48:06<br>Django version 3.1.7, using settings &#39;tutorial.settings&#39;<br>Starting development server at <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a><br>Quit the server with CONTROL-C.</pre><p>Ora apriamo il browser e andiamo a questo link <a href="http://localhost:8000/">http://localhost:8000/</a><br>E vedremo che il server sta funzionando ed è attivo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aGBiPW9j1qiFzP46L8JoYA.png" /><figcaption>Pagina iniziale per verificare che django sia installato correttamente</figcaption></figure><h3>Step 4: Migration</h3><p>Come probabilmente avete notato nello step prima, al lancio del server, è uscito un messaggio di warning:</p><blockquote>You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.<br>Run ‘python manage.py migrate’ to apply them.</blockquote><p>Django mette a disposizione un concetto di Migration.<br>Le migration (in poche parole) non sono altro che le azioni che servono per la gestione delle tabelle del database.<br>Infatti ad ogni nuova tabella che creeremo, verrà creato un nuovo file di migration, il quale si occupera di creare la tabella sul database.<br>Le migration in django sono importantissime perchè oltre ad toglierci un grosso peso dalla gestione del database, fornisce una storia del database stesso. Più avanti le vedremo nel dettaglio!</p><p>Ora applichiamole così da eliminare il warning, intanto stoppiamo il server (CTRL/CMD + C)</p><p>Eseguiamo il comando per l’applicazione delle migrazioni:</p><pre>➜ python manage.py migrate</pre><pre>Operations to perform:<br>  Apply all migrations: admin, auth, contenttypes, sessions<br>Running migrations:<br>  Applying contenttypes.0001_initial... OK<br>  Applying auth.0001_initial... OK<br>  Applying admin.0001_initial... OK<br>  Applying admin.0002_logentry_remove_auto_add... OK<br>  Applying admin.0003_logentry_add_action_flag_choices... OK<br>  Applying contenttypes.0002_remove_content_type_name... OK<br>  Applying auth.0002_alter_permission_name_max_length... OK<br>  Applying auth.0003_alter_user_email_max_length... OK<br>  Applying auth.0004_alter_user_username_opts... OK<br>  Applying auth.0005_alter_user_last_login_null... OK<br>  Applying auth.0006_require_contenttypes_0002... OK<br>  Applying auth.0007_alter_validators_add_error_messages... OK<br>  Applying auth.0008_alter_user_username_max_length... OK<br>  Applying auth.0009_alter_user_last_name_max_length... OK<br>  Applying auth.0010_alter_group_name_max_length... OK<br>  Applying auth.0011_update_proxy_permissions... OK<br>  Applying auth.0012_alter_user_first_name_max_length... OK<br>  Applying sessions.0001_initial... OK</pre><p>Ora se rilanciamo il server di sviluppo, vedremo che i warnings sono spariti:</p><pre>➜ python manage.py runserver</pre><pre>Watching for file changes with StatReloader<br>Performing system checks...</pre><pre>System check identified no issues (0 silenced).<br>March 27, 2021 - 15:55:38<br>Django version 3.1.7, using settings &#39;tutorial.settings&#39;<br>Starting development server at <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a><br>Quit the server with CONTROL-C.</pre><p>Probabilmente vi starete chiedendo:</p><blockquote>Django ha applicato le migrazioni al database, ma a che database le ha applicate?</blockquote><p>La risposta è <a href="https://www.sqlite.org/index.html">SQLite</a>. Django al primo avvio (prima che vengano impostate le configuarzioni), crea un piccolo database in SQLite dove vengono salvate le informazioni e applicate le migrazioni.</p><p>Infatti se guardate la cartella dove state lavorando, vedrete che si è aggiunto un file che si chiama <strong><em>db.sqlite3</em></strong>.</p><h3>Step 5: il primo utente e l’area di admin</h3><p>Django offre un potente panello di amministrazione a costo zero. Utilissimo per la gestione di gruppi, utenti e di tutte le risorse che andremo a creare nella nostra applicazione.</p><p>Per poter accedere, prima di tutto dobbiamo crearci un utente. Per farlo eseguiamo il seguente comando:</p><pre>➜ python manage.py createsuperuser</pre><pre>Username (leave blank to use &#39;mattia&#39;): mattia<br>Email address:<br>Password:<br>Password (again):<br>Superuser created successfully.</pre><p>Una volta creato il nostro utente, possiamo accedere all’area di amministrazione tramite questo link: <a href="http://localhost:8000/admin/">http://localhost:8000/admin/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3_Snt8haQWSNbKTN4uxHA.png" /><figcaption>Pagina di amministrazione di default</figcaption></figure><h3>Conclusioni:</h3><p>Come avete visto, creare una piccola applicazione di django partendo da 0 è molto semplice. Fortunatamente il framework ci mette a disposizione moltissimi strumenti utili alla nostra causa.</p><p>In questo repositori, è disponibile il codice che abbiamo appena visto insieme: <a href="https://github.com/mattiagiupponi/django-tutorial">https://github.com/mattiagiupponi/django-tutorial</a></p><p>Nel prossimo articolo vedremo come creare la nostra prima pagina.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e99f6e0839a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>