SlideShare uma empresa Scribd logo
1 de 63
Web Application Development
               Django Framework




              Fabrizio Lapiello
                       IT Eng. Student
                    http://flapiello.com
Table of contents
   “Step by Step”




                    2
Table of contents
             “Step by Step”


Step 0: Django Introduction
Step 1: Admin Panel
Step 2: URL
Step 3: Creating an application




                                  2
Step 0
Introduction: Django Framework




                                 3
Step 0
    Introduction: Django Framework


0) The Framework
1) MTV Pattern
2) DBMS
3) Setup
4) “Hello World”
 4.1) Creating and compiling
 4.2) Creating a View
                                     3
The Framework:
What is Django?




                  4
The Framework:
               What is Django?
Django is a great framework for building Web 2.0 applications!
  It 'was designed to improve development time and quality.




                   http://www.djangoproject.org




                                                                 4
MTV Pattern
“Model-Template-View”




                        5
MTV Pattern
              “Model-Template-View”
A pattern that helps to separate the user interface level from
  the other parts of the system.

Model - contains classes whose
 instances represent the data to
 display and manipulate.
Template - contains objects that
  control and manage user interaction
  with the model and view layers.
View - contains the objects used in the
  UI to display the data in the model.




                                                                 5
DBMS
        “Database management system”
Some of the most well-known DBMS used in Django:




                                                   6
DBMS
        “Database management system”
Some of the most well-known DBMS used in Django:




                                                   6
Prior Knowledge




                  7
Prior Knowledge




     ...that’s all!




                      7
Good reasons to learn Python
Well-known companies have adopted it for their business:




                                                           8
Good reasons to learn Python
Well-known companies have adopted it for their business:




                                                           8
Setup




        9
Setup
Download:
   http://www.djangoproject.com/download/


Setup Guide:
   http://docs.djangoproject.com/en/dev/intro/install/


Official Documentation:
   http://docs.djangoproject.com/




                                                         9
Creating and compiling project




                                 10
Creating and compiling project
$ django-admin.py startproject hello
      -> __Init__.py
         manage.py
         settings.py
         urls.py

$ python manage.py runserver
      -> 0 Error Found
      http://127.0.0.1:8000 -> Worked!!




                                          10
Creating a view
   First Step




                  11
Creating a view
                            First Step
First of all combining a URL to a view
   -> http://127.0.0.1:8000/hello


Open the file urls.py and insert the following string as the last
  parameter:
   -> (r’^hello/$’, “views.hello”)




                                                                    11
Creating a view
                            First Step
First of all combining a URL to a view
   -> http://127.0.0.1:8000/hello


Open the file urls.py and insert the following string as the last
  parameter:
   -> (r’^hello/$’, “views.hello”)




                                                                    11
Creating a view
                             First Step
First of all combining a URL to a view
    -> http://127.0.0.1:8000/hello


Open the file urls.py and insert the following string as the last
  parameter:
    -> (r’^hello/$’, “views.hello”)

  Regular expression that
indicates the beginning
and the end of the URL.




                                                                    11
Creating a view
                             First Step
First of all combining a URL to a view
    -> http://127.0.0.1:8000/hello


Open the file urls.py and insert the following string as the last
  parameter:
    -> (r’^hello/$’, “views.hello”)

  Regular expression that
indicates the beginning
and the end of the URL.




                                                                    11
Creating a view
                                First Step
First of all combining a URL to a view
    -> http://127.0.0.1:8000/hello


Open the file urls.py and insert the following string as the last
  parameter:
    -> (r’^hello/$’, “views.hello”)

  Regular expression that
indicates the beginning     Combining Url/Vista
and the end of the URL.




                                                                    11
Creating a view
                          Second Step
The view is simply a Python method that returns the data.
In the root of the project we create the views.py file and insert the
   following method:


             from django.http import HttpResponse
             def hello(request):
                  return HttpResponse(“Hello World”)


Now type in a terminal:
$ python manage.py runserver


                                                                        12
Step 1
Admin Panel




              13
Step 1
               Admin Panel


0) Creating applications
1) Creating models
2) Add a Database
3) ORM
4) Creating Admin Panel


                             13
Creating Applications
Is good practice to structure the project into sub-applications in
   order to have greater control over the entire system to be
   developed!
$ python manage.py startapp test
If there aren't errors in the root of the project should have a folder
    named "test" with the following files inside
__init__.py
models.py
views.py
Inatalled_Apps indicate the presence in the settings.py file,
   application "test" by simply inserting his name in quotes at the
   bottom of the list.

                                                                         14
Creating models
Change the models.py file in the folder "test "...

       from django.db import models
       class Persona (models.Model):
         nome = models.CharField(max_length=50)
         cognome = models.CharField(max_length=50)
         def __unicode__(self):
              return u"%s %s" % (self.nome, self.cognome)
         class Meta:
              verbose_name_plural ="Persone"


                                                            15
Add a Database
Edit the settings.py file in the following way:

      DATABASES = {
          'default': {
              'ENGINE': 'sqlite3', #NAME del dbms es (oracle, mysql etc..)
              'NAME': 'test.db', #DB NAME
              'USER': '', #USERNAME
              'PASSWORD': '', #Password
              'HOST': '', #DMBS ADDRESS
              'PORT': '', #PORT
          }
      }

                                                                             16
ORM
“Object-Relational Mapping”




                              17
ORM
“Object-Relational Mapping”

        An ORM is a kind of linker between
          objects and relational databases.




                                              17
ORM
“Object-Relational Mapping”

        An ORM is a kind of linker between
          objects and relational databases.


        Through this linker the created objects
          with a high-level language are
          included in the relational database.




                                                  17
ORM
“Object-Relational Mapping”

        An ORM is a kind of linker between
          objects and relational databases.


        Through this linker the created objects
          with a high-level language are
          included in the relational database.




                                                  17
ORM
“Object-Relational Mapping”

        An ORM is a kind of linker between
          objects and relational databases.


        Through this linker the created objects
          with a high-level language are
          included in the relational database.




                                                  17
ORM
“Object-Relational Mapping”

        An ORM is a kind of linker between
          objects and relational databases.


        Through this linker the created objects
          with a high-level language are
          included in the relational database.



              $ python manage.py syncdb



                                                  17
Creating Admin Panel
                      First Step
Open the file settings.py INSTALLED_APPS and insert in the
  application for the board of directors as follows:



               INSTALLED_APPS = (
                 'django.contrib.auth',
                 'django.contrib.contenttypes',
                 'django.contrib.sessions',
                 'django.contrib.sites',
                 'django.contrib.messages',
                 'django.contrib.admin',
               )



                                                             18
Creating Admin Panel
                       Second Step
Associate a URL to the application, then edit the urls.py file as
  follows:
                   from django.contrib import admin
                   admin.autodiscover()

                   urlpatterns = patterns('',
                       (r'^admin/', include(admin.site.urls)),
                       (r'^hello/$', "views.hello"),
                   )




                                                                    19
Creating Admin Panel
                       Second Step
Associate a URL to the application, then edit the urls.py file as
  follows:
                   from django.contrib import admin
                   admin.autodiscover()

                   urlpatterns = patterns('',




                                                         !
                       (r'^admin/', include(admin.site.urls)),




                                                      là
                       (r'^hello/$', "views.hello"),




                                                   oi
                   )




                            E t                   V
                                                                    19
Step 2
 URL




         20
Step 2
                     URL



0) URL
1) Creating an URL




                           20
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable


   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog




                                                                                                     21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable


   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog




                                                                                                     21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable


   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog




                                                                                                     21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                    n g!
                                                                                            yi
                                                                                      r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog




                                                                                                       21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                    n g!
                                                                                            yi
                                                                                      r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog




                                                                                                       21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
URL
                 Uniform Resource Locator
Benefit of having "ordered" URL
   - Easy to remember
   - Palatability by search engines
   - Durable                                                                                      n g!
                                                                                              yi
                                                                                        r rif
                                                                                   Ho
   Example:
   1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17


   2) http://nomedominio.com/blog
                                                                                   to
                                                                                        be
                                                                                             rep
                                                                                                   lac
                                                                                                         ed


                                                                                                              21
Creating URL
To create a URL like the following
   -> http://127.0.0.1:8000/hello
you have to combine the view of the URL, so, you have to open the
  file urls.py and insert the following string as the last parameter:
   -> (r’^hello/$’, “views.hello”)




                                                                        22
Creating URL
To create a URL like the following
   -> http://127.0.0.1:8000/hello
you have to combine the view of the URL, so, you have to open the
  file urls.py and insert the following string as the last parameter:
   -> (r’^hello/$’, “views.hello”)




                                                                        22
Creating URL
To create a URL like the following
   -> http://127.0.0.1:8000/hello
you have to combine the view of the URL, so, you have to open the
  file urls.py and insert the following string as the last parameter:
   -> (r’^hello/$’, “views.hello”)




                                                                        22
Creating URL
To create a URL like the following
   -> http://127.0.0.1:8000/hello
you have to combine the view of the URL, so, you have to open the
  file urls.py and insert the following string as the last parameter:
   -> (r’^hello/$’, “views.hello”)
  Regular expression that
indicates the beginning
and the end of the URL.




                                                                        22
Creating URL
To create a URL like the following
   -> http://127.0.0.1:8000/hello
you have to combine the view of the URL, so, you have to open the
  file urls.py and insert the following string as the last parameter:
   -> (r’^hello/$’, “views.hello”)
  Regular expression that
indicates the beginning     Combining Url/Vista
and the end of the URL.




                                                                        22
Step 3
Creating an application




                          23
Step 3
Creating an application




  DEMO
                          23
Contacts
 A Q
F      Fabrizio Lapiello
       IT Eng. Student
       Email: flapiello@aol.com
       Web: http://lfapiello.com

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

django
djangodjango
django
 
Free django
Free djangoFree django
Free django
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Flask
FlaskFlask
Flask
 
Building Pluggable Web Applications using Django
Building Pluggable Web Applications using DjangoBuilding Pluggable Web Applications using Django
Building Pluggable Web Applications using Django
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Aulas 6: usando o Jest para fazer mocks to Mongoose, testando a função save
Aulas 6: usando o Jest para fazer mocks to Mongoose, testando a função saveAulas 6: usando o Jest para fazer mocks to Mongoose, testando a função save
Aulas 6: usando o Jest para fazer mocks to Mongoose, testando a função save
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Express JS
Express JSExpress JS
Express JS
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
Basic Python Django
Basic Python DjangoBasic Python Django
Basic Python Django
 
PHP
PHPPHP
PHP
 

Semelhante a Web application development with Django framework

Django is a high-level Python web framework that enables rapid development of...
Django is a high-level Python web framework that enables rapid development of...Django is a high-level Python web framework that enables rapid development of...
Django is a high-level Python web framework that enables rapid development of...
ArijitDutta80
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
Ilian Iliev
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
Borni DHIFI
 

Semelhante a Web application development with Django framework (20)

Django by rj
Django by rjDjango by rj
Django by rj
 
Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
 
Django
DjangoDjango
Django
 
DJango
DJangoDJango
DJango
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 
Django is a high-level Python web framework that enables rapid development of...
Django is a high-level Python web framework that enables rapid development of...Django is a high-level Python web framework that enables rapid development of...
Django is a high-level Python web framework that enables rapid development of...
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
React django
React djangoReact django
React django
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
Building Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTMLBuilding Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTML
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4
 
Django - basics
Django - basicsDjango - basics
Django - basics
 
Build and deploy Python Django project
Build and deploy Python Django projectBuild and deploy Python Django project
Build and deploy Python Django project
 
RoR guide_p1
RoR guide_p1RoR guide_p1
RoR guide_p1
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
Drupal 8 preview_slideshow
Drupal 8 preview_slideshowDrupal 8 preview_slideshow
Drupal 8 preview_slideshow
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Web application development with Django framework

  • 1. Web Application Development Django Framework Fabrizio Lapiello IT Eng. Student http://flapiello.com
  • 2. Table of contents “Step by Step” 2
  • 3. Table of contents “Step by Step” Step 0: Django Introduction Step 1: Admin Panel Step 2: URL Step 3: Creating an application 2
  • 5. Step 0 Introduction: Django Framework 0) The Framework 1) MTV Pattern 2) DBMS 3) Setup 4) “Hello World” 4.1) Creating and compiling 4.2) Creating a View 3
  • 7. The Framework: What is Django? Django is a great framework for building Web 2.0 applications! It 'was designed to improve development time and quality. http://www.djangoproject.org 4
  • 9. MTV Pattern “Model-Template-View” A pattern that helps to separate the user interface level from the other parts of the system. Model - contains classes whose instances represent the data to display and manipulate. Template - contains objects that control and manage user interaction with the model and view layers. View - contains the objects used in the UI to display the data in the model. 5
  • 10. DBMS “Database management system” Some of the most well-known DBMS used in Django: 6
  • 11. DBMS “Database management system” Some of the most well-known DBMS used in Django: 6
  • 13. Prior Knowledge ...that’s all! 7
  • 14. Good reasons to learn Python Well-known companies have adopted it for their business: 8
  • 15. Good reasons to learn Python Well-known companies have adopted it for their business: 8
  • 16. Setup 9
  • 17. Setup Download: http://www.djangoproject.com/download/ Setup Guide: http://docs.djangoproject.com/en/dev/intro/install/ Official Documentation: http://docs.djangoproject.com/ 9
  • 19. Creating and compiling project $ django-admin.py startproject hello -> __Init__.py manage.py settings.py urls.py $ python manage.py runserver -> 0 Error Found http://127.0.0.1:8000 -> Worked!! 10
  • 20. Creating a view First Step 11
  • 21. Creating a view First Step First of all combining a URL to a view -> http://127.0.0.1:8000/hello Open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 11
  • 22. Creating a view First Step First of all combining a URL to a view -> http://127.0.0.1:8000/hello Open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 11
  • 23. Creating a view First Step First of all combining a URL to a view -> http://127.0.0.1:8000/hello Open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression that indicates the beginning and the end of the URL. 11
  • 24. Creating a view First Step First of all combining a URL to a view -> http://127.0.0.1:8000/hello Open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression that indicates the beginning and the end of the URL. 11
  • 25. Creating a view First Step First of all combining a URL to a view -> http://127.0.0.1:8000/hello Open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression that indicates the beginning Combining Url/Vista and the end of the URL. 11
  • 26. Creating a view Second Step The view is simply a Python method that returns the data. In the root of the project we create the views.py file and insert the following method: from django.http import HttpResponse def hello(request): return HttpResponse(“Hello World”) Now type in a terminal: $ python manage.py runserver 12
  • 28. Step 1 Admin Panel 0) Creating applications 1) Creating models 2) Add a Database 3) ORM 4) Creating Admin Panel 13
  • 29. Creating Applications Is good practice to structure the project into sub-applications in order to have greater control over the entire system to be developed! $ python manage.py startapp test If there aren't errors in the root of the project should have a folder named "test" with the following files inside __init__.py models.py views.py Inatalled_Apps indicate the presence in the settings.py file, application "test" by simply inserting his name in quotes at the bottom of the list. 14
  • 30. Creating models Change the models.py file in the folder "test "... from django.db import models class Persona (models.Model): nome = models.CharField(max_length=50) cognome = models.CharField(max_length=50) def __unicode__(self): return u"%s %s" % (self.nome, self.cognome) class Meta: verbose_name_plural ="Persone" 15
  • 31. Add a Database Edit the settings.py file in the following way: DATABASES = { 'default': { 'ENGINE': 'sqlite3', #NAME del dbms es (oracle, mysql etc..) 'NAME': 'test.db', #DB NAME 'USER': '', #USERNAME 'PASSWORD': '', #Password 'HOST': '', #DMBS ADDRESS 'PORT': '', #PORT } } 16
  • 33. ORM “Object-Relational Mapping” An ORM is a kind of linker between objects and relational databases. 17
  • 34. ORM “Object-Relational Mapping” An ORM is a kind of linker between objects and relational databases. Through this linker the created objects with a high-level language are included in the relational database. 17
  • 35. ORM “Object-Relational Mapping” An ORM is a kind of linker between objects and relational databases. Through this linker the created objects with a high-level language are included in the relational database. 17
  • 36. ORM “Object-Relational Mapping” An ORM is a kind of linker between objects and relational databases. Through this linker the created objects with a high-level language are included in the relational database. 17
  • 37. ORM “Object-Relational Mapping” An ORM is a kind of linker between objects and relational databases. Through this linker the created objects with a high-level language are included in the relational database. $ python manage.py syncdb 17
  • 38. Creating Admin Panel First Step Open the file settings.py INSTALLED_APPS and insert in the application for the board of directors as follows: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', ) 18
  • 39. Creating Admin Panel Second Step Associate a URL to the application, then edit the urls.py file as follows: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), (r'^hello/$', "views.hello"), ) 19
  • 40. Creating Admin Panel Second Step Associate a URL to the application, then edit the urls.py file as follows: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', ! (r'^admin/', include(admin.site.urls)), là (r'^hello/$', "views.hello"), oi ) E t V 19
  • 42. Step 2 URL 0) URL 1) Creating an URL 20
  • 43. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog 21
  • 44. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog 21
  • 45. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog 21
  • 46. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog 21
  • 47. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog 21
  • 48. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 49. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 50. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 51. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 52. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 53. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 54. URL Uniform Resource Locator Benefit of having "ordered" URL - Easy to remember - Palatability by search engines - Durable n g! yi r rif Ho Example: 1) http://nomedominio.com/index.php?option=com_content&view=category&layout=blog&id=3&Itemid=17 2) http://nomedominio.com/blog to be rep lac ed 21
  • 55. Creating URL To create a URL like the following -> http://127.0.0.1:8000/hello you have to combine the view of the URL, so, you have to open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 22
  • 56. Creating URL To create a URL like the following -> http://127.0.0.1:8000/hello you have to combine the view of the URL, so, you have to open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 22
  • 57. Creating URL To create a URL like the following -> http://127.0.0.1:8000/hello you have to combine the view of the URL, so, you have to open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 22
  • 58. Creating URL To create a URL like the following -> http://127.0.0.1:8000/hello you have to combine the view of the URL, so, you have to open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression that indicates the beginning and the end of the URL. 22
  • 59. Creating URL To create a URL like the following -> http://127.0.0.1:8000/hello you have to combine the view of the URL, so, you have to open the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression that indicates the beginning Combining Url/Vista and the end of the URL. 22
  • 60. Step 3 Creating an application 23
  • 61. Step 3 Creating an application DEMO 23
  • 62.
  • 63. Contacts A Q F Fabrizio Lapiello IT Eng. Student Email: flapiello@aol.com Web: http://lfapiello.com

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n