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.
Web Application Development               Django Framework              Fabrizio Lapiello                       IT Eng. St...
Table of contents   “Step by Step”                    2
Table of contents             “Step by Step”Step 0: Django IntroductionStep 1: Admin PanelStep 2: URLStep 3: Creating an a...
Step 0Introduction: Django Framework                                 3
Step 0    Introduction: Django Framework0) The Framework1) MTV Pattern2) DBMS3) Setup4) “Hello World” 4.1) Creating and co...
The Framework:What is Django?                  4
The Framework:               What is Django?Django is a great framework for building Web 2.0 applications!  It was designe...
MTV Pattern“Model-Template-View”                        5
MTV Pattern              “Model-Template-View”A pattern that helps to separate the user interface level from  the other pa...
DBMS        “Database management system”Some of the most well-known DBMS used in Django:                                  ...
DBMS        “Database management system”Some of the most well-known DBMS used in Django:                                  ...
Prior Knowledge                  7
Prior Knowledge     ...that’s all!                      7
Good reasons to learn PythonWell-known companies have adopted it for their business:                                      ...
Good reasons to learn PythonWell-known companies have adopted it for their business:                                      ...
Setup        9
SetupDownload:   http://www.djangoproject.com/download/Setup Guide:   http://docs.djangoproject.com/en/dev/intro/install/O...
Creating and compiling project                                 10
Creating and compiling project$ django-admin.py startproject hello      -> __Init__.py         manage.py         settings....
Creating a view   First Step                  11
Creating a view                            First StepFirst of all combining a URL to a view   -> http://127.0.0.1:8000/hel...
Creating a view                            First StepFirst of all combining a URL to a view   -> http://127.0.0.1:8000/hel...
Creating a view                             First StepFirst of all combining a URL to a view    -> http://127.0.0.1:8000/h...
Creating a view                             First StepFirst of all combining a URL to a view    -> http://127.0.0.1:8000/h...
Creating a view                                First StepFirst of all combining a URL to a view    -> http://127.0.0.1:800...
Creating a view                          Second StepThe view is simply a Python method that returns the data.In the root o...
Step 1Admin Panel              13
Step 1               Admin Panel0) Creating applications1) Creating models2) Add a Database3) ORM4) Creating Admin Panel  ...
Creating ApplicationsIs good practice to structure the project into sub-applications in   order to have greater control ov...
Creating modelsChange the models.py file in the folder "test "...       from django.db import models       class Persona (...
Add a DatabaseEdit the settings.py file in the following way:      DATABASES = {          default: {              ENGINE: ...
ORM“Object-Relational Mapping”                              17
ORM“Object-Relational Mapping”        An ORM is a kind of linker between          objects and relational databases.       ...
ORM“Object-Relational Mapping”        An ORM is a kind of linker between          objects and relational databases.       ...
ORM“Object-Relational Mapping”        An ORM is a kind of linker between          objects and relational databases.       ...
ORM“Object-Relational Mapping”        An ORM is a kind of linker between          objects and relational databases.       ...
ORM“Object-Relational Mapping”        An ORM is a kind of linker between          objects and relational databases.       ...
Creating Admin Panel                      First StepOpen the file settings.py INSTALLED_APPS and insert in the  applicatio...
Creating Admin Panel                       Second StepAssociate a URL to the application, then edit the urls.py file as  f...
Creating Admin Panel                       Second StepAssociate a URL to the application, then edit the urls.py file as  f...
Step 2 URL         20
Step 2                     URL0) URL1) Creating an URL                           20
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
URL                 Uniform Resource LocatorBenefit of having "ordered" URL   - Easy to remember   - Palatability by searc...
Creating URLTo create a URL like the following   -> http://127.0.0.1:8000/helloyou have to combine the view of the URL, so...
Creating URLTo create a URL like the following   -> http://127.0.0.1:8000/helloyou have to combine the view of the URL, so...
Creating URLTo create a URL like the following   -> http://127.0.0.1:8000/helloyou have to combine the view of the URL, so...
Creating URLTo create a URL like the following   -> http://127.0.0.1:8000/helloyou have to combine the view of the URL, so...
Creating URLTo create a URL like the following   -> http://127.0.0.1:8000/helloyou have to combine the view of the URL, so...
Step 3Creating an application                          23
Step 3Creating an application  DEMO                          23
Contacts A QF      Fabrizio Lapiello       IT Eng. Student       Email: flapiello@aol.com       Web: http://lfapiello.com
Web application development with Django framework
Upcoming SlideShare
Loading in …5
×

Web application development with Django framework

2,355 views

Published on

Introduction to Django Framework

Published in: Technology
  • Be the first to comment

Web application development with Django framework

  1. 1. Web Application Development Django Framework Fabrizio Lapiello IT Eng. Student http://flapiello.com
  2. 2. Table of contents “Step by Step” 2
  3. 3. Table of contents “Step by Step”Step 0: Django IntroductionStep 1: Admin PanelStep 2: URLStep 3: Creating an application 2
  4. 4. Step 0Introduction: Django Framework 3
  5. 5. Step 0 Introduction: Django Framework0) The Framework1) MTV Pattern2) DBMS3) Setup4) “Hello World” 4.1) Creating and compiling 4.2) Creating a View 3
  6. 6. The Framework:What is Django? 4
  7. 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
  8. 8. MTV Pattern“Model-Template-View” 5
  9. 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. 10. DBMS “Database management system”Some of the most well-known DBMS used in Django: 6
  11. 11. DBMS “Database management system”Some of the most well-known DBMS used in Django: 6
  12. 12. Prior Knowledge 7
  13. 13. Prior Knowledge ...that’s all! 7
  14. 14. Good reasons to learn PythonWell-known companies have adopted it for their business: 8
  15. 15. Good reasons to learn PythonWell-known companies have adopted it for their business: 8
  16. 16. Setup 9
  17. 17. SetupDownload: http://www.djangoproject.com/download/Setup Guide: http://docs.djangoproject.com/en/dev/intro/install/Official Documentation: http://docs.djangoproject.com/ 9
  18. 18. Creating and compiling project 10
  19. 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. 20. Creating a view First Step 11
  21. 21. Creating a view First StepFirst of all combining a URL to a view -> http://127.0.0.1:8000/helloOpen the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 11
  22. 22. Creating a view First StepFirst of all combining a URL to a view -> http://127.0.0.1:8000/helloOpen the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) 11
  23. 23. Creating a view First StepFirst of all combining a URL to a view -> http://127.0.0.1:8000/helloOpen the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression thatindicates the beginningand the end of the URL. 11
  24. 24. Creating a view First StepFirst of all combining a URL to a view -> http://127.0.0.1:8000/helloOpen the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression thatindicates the beginningand the end of the URL. 11
  25. 25. Creating a view First StepFirst of all combining a URL to a view -> http://127.0.0.1:8000/helloOpen the file urls.py and insert the following string as the last parameter: -> (r’^hello/$’, “views.hello”) Regular expression thatindicates the beginning Combining Url/Vistaand the end of the URL. 11
  26. 26. Creating a view Second StepThe 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
  27. 27. Step 1Admin Panel 13
  28. 28. Step 1 Admin Panel0) Creating applications1) Creating models2) Add a Database3) ORM4) Creating Admin Panel 13
  29. 29. Creating ApplicationsIs 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 testIf there arent errors in the root of the project should have a folder named "test" with the following files inside__init__.pymodels.pyviews.pyInatalled_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. 30. Creating modelsChange 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. 31. Add a DatabaseEdit 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
  32. 32. ORM“Object-Relational Mapping” 17
  33. 33. ORM“Object-Relational Mapping” An ORM is a kind of linker between objects and relational databases. 17
  34. 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. 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. 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. 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. 38. Creating Admin Panel First StepOpen 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. 39. Creating Admin Panel Second StepAssociate 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. 40. Creating Admin Panel Second StepAssociate 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
  41. 41. Step 2 URL 20
  42. 42. Step 2 URL0) URL1) Creating an URL 20
  43. 43. URL Uniform Resource LocatorBenefit 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. 44. URL Uniform Resource LocatorBenefit 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. 45. URL Uniform Resource LocatorBenefit 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. 46. URL Uniform Resource LocatorBenefit 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. 47. URL Uniform Resource LocatorBenefit 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. 48. URL Uniform Resource LocatorBenefit 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. 49. URL Uniform Resource LocatorBenefit 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. 50. URL Uniform Resource LocatorBenefit 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. 51. URL Uniform Resource LocatorBenefit 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. 52. URL Uniform Resource LocatorBenefit 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. 53. URL Uniform Resource LocatorBenefit 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. 54. URL Uniform Resource LocatorBenefit 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. 55. Creating URLTo create a URL like the following -> http://127.0.0.1:8000/helloyou 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. 56. Creating URLTo create a URL like the following -> http://127.0.0.1:8000/helloyou 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. 57. Creating URLTo create a URL like the following -> http://127.0.0.1:8000/helloyou 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. 58. Creating URLTo create a URL like the following -> http://127.0.0.1:8000/helloyou 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 thatindicates the beginningand the end of the URL. 22
  59. 59. Creating URLTo create a URL like the following -> http://127.0.0.1:8000/helloyou 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 thatindicates the beginning Combining Url/Vistaand the end of the URL. 22
  60. 60. Step 3Creating an application 23
  61. 61. Step 3Creating an application DEMO 23
  62. 62. Contacts A QF Fabrizio Lapiello IT Eng. Student Email: flapiello@aol.com Web: http://lfapiello.com

×