Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Django introduction

5,954 views

Published on

Published in: Technology
  • Dating direct: ❤❤❤ http://bit.ly/2Qu6Caa ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❤❤❤ http://bit.ly/2Qu6Caa ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Django introduction

  1. 1. Introduzione Valeria Leonardi @vleonardi Django night – 21 ottobre 2011
  2. 2. <ul><li>The (Python) Web framework for perfectionists with deadlines </li></ul>
  3. 3. <ul><li>Interpretato </li></ul><ul><li>Interattivo </li></ul><ul><li>Multiparadigma </li></ul><ul><ul><li>OO, programmazione strutturata.. </li></ul></ul><ul><li>Indentazione per la definizione di blocchi </li></ul><ul><li>Dynamic typing </li></ul><ul><li>Modulare </li></ul>
  4. 4. Web-Poll Application
  5. 5. 3....2....1.... <ul><li>Installare Python (2.3 <= versione <= 2.7) </li></ul><ul><li>Installare Django </li></ul><ul><li>Installare (eventuale) adattatore python per il db </li></ul>
  6. 6. ... Let’s start ! <ul><li>Project </li></ul><ul><ul><li>django-admin.py startproject demoProject </li></ul></ul><ul><ul><li>demoProject / </li></ul></ul><ul><ul><ul><li>__init__.py </li></ul></ul></ul><ul><ul><ul><li>manage.py </li></ul></ul></ul><ul><ul><ul><li>settings.py </li></ul></ul></ul><ul><ul><ul><li>urls.py </li></ul></ul></ul><ul><li>App </li></ul><ul><ul><li>python manage.py startapp polls </li></ul></ul><ul><ul><li>polls/ </li></ul></ul><ul><ul><ul><li>__init__.py </li></ul></ul></ul><ul><ul><ul><li>models.py </li></ul></ul></ul><ul><ul><ul><li>tests.py </li></ul></ul></ul><ul><ul><ul><li>views.py </li></ul></ul></ul>
  7. 7. MVC vs. MTV M Model V View C Controller M Model T Template V View C Controller Django Framework
  8. 8. Model <ul><li>Model: classe Python </li></ul><ul><li>Installare models nel progetto </li></ul><ul><ul><li>Settings  aggiungere la nostra app </li></ul></ul><ul><ul><li>Settings  set engine e name </li></ul></ul><ul><li>python manage.py sql polls </li></ul><ul><li>python manage.py syncdb </li></ul>
  9. 9. View <ul><li>View </li></ul><ul><ul><li>Return HttpResponse object OR </li></ul></ul><ul><ul><li>Raise an exception </li></ul></ul><ul><li>Esempio: </li></ul><ul><ul><li>Index </li></ul></ul><ul><ul><li>Detail </li></ul></ul><ul><ul><li>Vote </li></ul></ul><ul><ul><li>Results </li></ul></ul>
  10. 10. Template e Url <ul><li>Templates: </li></ul><ul><ul><li>Index.html </li></ul></ul><ul><ul><li>Details.html </li></ul></ul><ul><ul><li>Results.html </li></ul></ul><ul><li>“ Masterpage”: base.html </li></ul><ul><li>URL.py: regole di routing </li></ul><ul><ul><li>(regular expression, Python callback function [, optional dictionary]) </li></ul></ul>
  11. 11. «Batteries included» <ul><li>Django.contrib: </li></ul><ul><ul><li>Admin-site </li></ul></ul><ul><ul><li>Authentication </li></ul></ul><ul><ul><li>Formtools </li></ul></ul><ul><ul><li>Gis </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><li>Abilitare Admin-site </li></ul><ul><ul><li>INSTALLED_APPS </li></ul></ul><ul><ul><li>URLS </li></ul></ul><ul><ul><li>admin.py </li></ul></ul><ul><ul><li>Python manage.py createsuperuser </li></ul></ul>

×