Nagi Reddy A
Mphasis.
Agenda:
What is Django?
Django architecture.
Why Django for Web Development?
Language of Choice.
Components of Django.
Getting started with Django.
Summary.
What is Django?
 Django is pronounced JANG-oh. The “D” is silent.
 Django is a powerful Python web framework, it is free, simple and very fast!
 Beautiful & flexible design and Great documentation.
 Primary Focus
 Dynamic and database driven websites
 History
 Named after famous Guitarist “Django Reinhardt”
 Developed by Adrian Holovaty and Jacob Kaplan-moss at World Online News for
efficient development
 Open sourced in 2005
 First Version released September in 3, 2008
Django
Architecture:
The blue boxes are what things are called, the purple ones is a
try to be more concrete in what they mean.
Why Django for Web
Development:
 Provides MVC(T) design.
 Provides auto generated web admin.
 Provides you template system to define HTML
template for your web pages to avoid code duplication.
 Don’t Repeat Yourself (DRY) Principle.
 Allows you to define what URL be for a given Function.
 Loosely Coupled Principle.
 Everything is in python (schema/settings).
Language of choice
:
 The organizations attracting the
best programmers in the world Mozilla, Instagram,
Open stack ,Google
• Such as:
Components :
 The core Django MVC(T).
 A lightweight, standalone web server for development and testing.
 A form serialization and validation system which can translate
between HTML forms and values suitable for storage in the database.
 An interface to Python's built-in unit test framework.
 An internationalization system, including translations of
Django's own components into a variety of languages.
 A serialization system which can produce and read
XML and/or JSON representations of Django model instances.
 Tools for generating Google Sitemaps.
Create a
Project:
django-admin startproject mysite – Creates a Project named “mysite”.
This creates a mysite directory which contains:
 manage.py
 mysite
 __init__.py
 settings.py
 urls.py
 wsgi.py
python manage.py runserver – Start the server(internal for development &
testing) Can be configure and use apache.
Development server is running at
 http://127.0.0.1:8000/ (default, which can be change)
urls.py
 This is a full url configuration file. To the left you have a list of regular
expressions, to the right you have a list of functions to run when an
URL matches that regexp. Every pair of parenthesis inside the regexps
are variables that are sent as arguments to the view.
views.py
And this is a view. But you can’t have html in the code like
that can you?
Template Settings :
• And this is how the template looks. Use dot‐syntax to access
properties, and for‐loops to access things in lists. Pipe chars, |, can
be used for filter variables (in this case ”upper” is a filter) and
django comes with a very good list of default filters.
11
Models.py
• The model! This is what you need to do to store information
about a person. Just list the fields you want, there are many field
types to choose from. When you’re done, go to the console and
type the line at the bottom. Then, your model is ready to use...
12
Django Free automatic admin interface:
Djangos automatic interface. It looks at your model and just
renders an interface based on that information. This interface is
also highly configurable. Demo…
13
Summary :
Django is a high-level Python Web framework.
DRY (Don’t Repeat Yourself) principle.
Automatic admin interface
Elegant URL design
Template system.
Cache system – Super Performance.
Internationalization – Multi-Language Applications.
Well, it’s uncomfortable at first.
One of the best things about Django is its documentation. It rocks.
Really.
Django is also under active development.
Finally It’s Open sourced.
Major Differences 1.5 to to 1.7
• Django 1.7 has migrations(Python manage.py Migrate)
• simple json is depreciated in 1.6
• Django 1.6 has a new directory structure
• Django 1.6 has ALLOWED_HOST setting
• Django 1.6 has new logging configurations
• Django 1.7 has new app + celery configurations.
Django Introdcution
Django Introdcution

Django Introdcution

  • 1.
  • 2.
    Agenda: What is Django? Djangoarchitecture. Why Django for Web Development? Language of Choice. Components of Django. Getting started with Django. Summary.
  • 3.
    What is Django? Django is pronounced JANG-oh. The “D” is silent.  Django is a powerful Python web framework, it is free, simple and very fast!  Beautiful & flexible design and Great documentation.  Primary Focus  Dynamic and database driven websites  History  Named after famous Guitarist “Django Reinhardt”  Developed by Adrian Holovaty and Jacob Kaplan-moss at World Online News for efficient development  Open sourced in 2005  First Version released September in 3, 2008
  • 4.
    Django Architecture: The blue boxesare what things are called, the purple ones is a try to be more concrete in what they mean.
  • 5.
    Why Django forWeb Development:  Provides MVC(T) design.  Provides auto generated web admin.  Provides you template system to define HTML template for your web pages to avoid code duplication.  Don’t Repeat Yourself (DRY) Principle.  Allows you to define what URL be for a given Function.  Loosely Coupled Principle.  Everything is in python (schema/settings).
  • 6.
    Language of choice : The organizations attracting the best programmers in the world Mozilla, Instagram, Open stack ,Google • Such as:
  • 7.
    Components :  Thecore Django MVC(T).  A lightweight, standalone web server for development and testing.  A form serialization and validation system which can translate between HTML forms and values suitable for storage in the database.  An interface to Python's built-in unit test framework.  An internationalization system, including translations of Django's own components into a variety of languages.  A serialization system which can produce and read XML and/or JSON representations of Django model instances.  Tools for generating Google Sitemaps.
  • 8.
    Create a Project: django-admin startprojectmysite – Creates a Project named “mysite”. This creates a mysite directory which contains:  manage.py  mysite  __init__.py  settings.py  urls.py  wsgi.py python manage.py runserver – Start the server(internal for development & testing) Can be configure and use apache. Development server is running at  http://127.0.0.1:8000/ (default, which can be change)
  • 9.
    urls.py  This isa full url configuration file. To the left you have a list of regular expressions, to the right you have a list of functions to run when an URL matches that regexp. Every pair of parenthesis inside the regexps are variables that are sent as arguments to the view.
  • 10.
    views.py And this isa view. But you can’t have html in the code like that can you?
  • 11.
    Template Settings : •And this is how the template looks. Use dot‐syntax to access properties, and for‐loops to access things in lists. Pipe chars, |, can be used for filter variables (in this case ”upper” is a filter) and django comes with a very good list of default filters. 11
  • 12.
    Models.py • The model!This is what you need to do to store information about a person. Just list the fields you want, there are many field types to choose from. When you’re done, go to the console and type the line at the bottom. Then, your model is ready to use... 12
  • 13.
    Django Free automaticadmin interface: Djangos automatic interface. It looks at your model and just renders an interface based on that information. This interface is also highly configurable. Demo… 13
  • 14.
    Summary : Django isa high-level Python Web framework. DRY (Don’t Repeat Yourself) principle. Automatic admin interface Elegant URL design Template system. Cache system – Super Performance. Internationalization – Multi-Language Applications. Well, it’s uncomfortable at first. One of the best things about Django is its documentation. It rocks. Really. Django is also under active development. Finally It’s Open sourced.
  • 15.
    Major Differences 1.5to to 1.7 • Django 1.7 has migrations(Python manage.py Migrate) • simple json is depreciated in 1.6 • Django 1.6 has a new directory structure • Django 1.6 has ALLOWED_HOST setting • Django 1.6 has new logging configurations • Django 1.7 has new app + celery configurations.