This document provides an introduction to web development with the Django framework. It outlines Django's project structure, how it handles data with models, and its built-in admin interface. It also covers views, templates, forms, and generic views. Django allows defining models as Python classes to represent the database structure. It provides a production-ready admin interface to manage data. URLs are mapped to views, which can render templates to generate responses. Forms validate and display data. Generic views handle common tasks like displaying object lists.
The document discusses Django, a Python web framework. It began as an internal project at a newspaper to help journalists meet deadlines. Django encourages rapid development, clean design and is database and platform neutral. It features an object relational mapper, automatic admin interface, elegant URLs and templates. Django uses a model-template-view architecture. It provides tools like manage.py to help with development.
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
Web development with django - Basics PresentationShrinath Shenoy
?
Django is a Python web framework that follows an MVT architecture. It uses ORM to interact with databases and includes templates to separate presentation from logic. Popular sites like Instagram and Mozilla use Django. A Django project is created using the startproject command and contains apps, URLs, views, models, forms, and templates. Django encourages DRY principles and reusability through its built-in features, plugins, and customizable components.
This session is about Django, which is a web framework build in python. It has several features like admin interface and ORM. The architecture of Django has Model, View, and template and it's ORM saves the pain of writing database queries.
Django is a free and open source web application framework, written in Python, which follows the Model¨CView¨CController architectural pattern.
It focuses on automating as much as possible and adhering to the DRY principle
This document provides an overview of the Django web framework. It discusses Django's mission of encouraging rapid development and clean design. It demonstrates how to create a blog application with Django, including generating models, activating the admin interface, defining URLs and views, and using templates to display data. It also briefly compares Django to other frameworks like Ruby on Rails.
Django is a high-level Python web framework that encourages rapid development and clean design. It makes building web apps faster with less code by providing models, templates, views, and URL patterns. To build a project, you create a project folder using startproject, then add apps using startapp which contain models, views, and other files. You sync the database, configure URLs and views, then run the development server to view your new app.
Neural networks are computational models inspired by the human brain. They consist of interconnected nodes that process information using a principle called neural learning. The document discusses the history and evolution of neural networks. It also provides examples of applications like image recognition, medical diagnosis, and predictive analytics. Neural networks are well-suited for problems that are difficult to solve with traditional algorithms like pattern recognition and classification.
ºÝºÝߣs from our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
Django is a Python web framework that encourages rapid development and clean design. It includes an ORM, URL routing, templates, internationalization support, caching, authentication, and an admin interface. Django uses the MVT architecture, with Models handling data, Views returning responses, and Templates rendering output. Requests go through the URL dispatcher to Views, which can retrieve Model data and pass it to Templates to generate responses. The framework provides tools to define Models, URLs, Views and Templates to build applications.
Sanjay Rathore presents an introduction to the Django web framework. He discusses key features of Django including rapid development, security, and scalability. He outlines the MVT (Model View Template) architecture, describing the roles of each component. He also demonstrates how to install Django, set up a virtual environment, and build a basic MVT application with URL routing and templates. Pros of Django include its Python-based code, database management, and security, while cons are its potential heaviness for small projects.
- The document describes the process of setting up a Django web application project called Learning Log. This includes creating a virtual environment, installing Django, creating a Django project and app, defining models, registering models with the admin site, adding data to the models, and making initial pages by defining a URL pattern and view function. The goal of the Learning Log project is to allow users to log topics they are interested in and make journal entries about each topic.
This document introduces Flask, a Python framework for building web applications. It explains that Flask uses Python decorators to define routes for the web server. Before writing a Flask application, the reader is instructed to install Python, pip, virtualenv, and Flask within a new project directory. The basics of writing a Flask application are then covered, including running the application and defining routes to return responses. The document ends with quiz questions and resources for learning more about Flask.
This document provides an overview of Flask, a microframework for Python. It discusses that Flask is easy to code and configure, extensible via extensions, and uses Jinja2 templating and SQLAlchemy ORM. It then provides a step-by-step guide to setting up a Flask application, including creating a virtualenv, basic routing, models, forms, templates, and views. Configuration and running the application are also covered at a high level.
This document provides an overview of the Django web framework. It begins with definitions of Django and the MTV architectural pattern it follows. It then explains the differences between MTV and traditional MVC. Models, templates, and views are described as the core components of MTV. The document outlines Django's installation process and project structure. It also discusses Django's database API and advantages such as ORM support, multilingualism, and administration interfaces. Popular websites that use Django are listed before the document concludes by praising Django's security features and database API.
The document provides an overview of working with JSON (JavaScript Object Notation). It introduces JSON, explaining its need and comparing it to XML. It describes JSON syntax rules, data types, objects, and arrays. It discusses how JSON uses JavaScript syntax and can be used in files. The document also covers JSON security concerns, using JSON with JavaScript functions, client-side frameworks, server-side frameworks, replacing XML with JSON, and parsing and AJAX with JSON and jQuery.
Django Tutorial | Django Web Development With Python | Django Training and Ce...Edureka!
?
( Python Django Training - https://www.edureka.co/python-django )
This Edureka ¡°Django Tutorial" introduces you to django along with a practical to create web application using python web framework. This video helps you to learn following topics:
1. Why Django framework?
2. What is Django?
3. Architecture: MVC-MVT Pattern
4. Hands On: Getting started with Django
5. Building blocks of Django
6. Project: A web application
This document provides an overview of Angular, including:
- Angular is a JavaScript framework used to build client-side applications with HTML. Code is written in TypeScript which compiles to JavaScript.
- Angular enhances HTML with directives, data binding, and dependency injection. It follows an MVC architecture internally.
- Components are the basic building blocks of Angular applications. Modules contain components and services. Services contain reusable business logic.
- The document discusses Angular concepts like modules, components, data binding, services, routing and forms. It provides examples of creating a sample login/welcome application in Angular.
This document provides an overview and introduction to Django Girls training on Django and web development. It covers the following key points:
- Django is a Python web framework that makes building websites faster and easier. It includes components that handle common tasks like database access.
- The tutorial will teach you to build a simple blog application. By the end, you will have a working blog that you can deploy for others to see online.
- It introduces important concepts like how the internet works, what the command line is, what Django is, why frameworks are useful, and how requests are handled in Django.
- It provides instructions on installing Django and setting up a development environment with a virtual environment and SQLite database.
Server-side programming involves writing code that runs on a web server using languages like Java, PHP, and C#. It processes user input, displays pages, structures applications, and interacts with storage. Client-side programming writes code that runs in the user's browser using JavaScript. In a typical interaction, a user's browser requests a page from a server, which processes the request and returns the page which is then rendered in the browser. Common server-side programming languages and frameworks include PHP, Python, and ASP.Net. Web pages can be static with fixed HTML content or dynamic where the content changes based on server-side processing.
This document introduces Django, an open-source Python web framework. It describes Django's key features like rapid development, reusable apps, an admin interface, and templates. It explains Django's model-view-template architecture, including models for defining data, views for business logic, URLs for routing, and templates for presentation. It provides examples of defining a blog application in Django with models, views, URLs, and templates.
The document describes the Model-View-Controller (MVC) software architectural pattern. MVC separates an application into three main components: the model, the view, and the controller. The model manages the application's data and business logic. The view displays the model's information. The controller interprets inputs from the user and updates the model and/or view accordingly. This separation of concerns makes the application modular, reusable, and maintainable.
This document provides an overview of key concepts in Django including: installation and setup using pip and virtual environments; the built-in admin interface; the model-view-template pattern; handling URLs and routes; middleware; static files; database migrations; model forms; and Django forms. It explains that Django is a Python web framework that handles common web development tasks to allow developers to focus on application code.
PHP is a server-side scripting language used to create dynamic web pages. It allows embedding PHP code within HTML pages and interacting with databases. Key elements of PHP include variables, control structures, functions, and sessions. Sessions store user data on the server instead of the client to avoid cookies and allow tracking users across multiple pages.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
( ** Python Certification Training: https://www.edureka.co/python ** )
This Edureka PPT on Tkinter tutorial covers all the basic aspects of creating and making use of your own simple Graphical User Interface (GUI) using Python. It establishes all of the concepts needed to get started with building your own user interfaces while coding in Python.
This document provides an introduction and overview of REST APIs. It defines REST as an architectural style based on web standards like HTTP that defines resources that are accessed via common operations like GET, PUT, POST, and DELETE. It outlines best practices for REST API design, including using nouns in URIs, plural resource names, GET for retrieval only, HTTP status codes, and versioning. It also covers concepts like filtering, sorting, paging, and common queries.
The document discusses the Django web application framework. It describes Django as a high-level Python framework that encourages rapid development and clean design. It outlines Django's architecture, which follows an MVT pattern with models, views, templates, and a URL dispatcher. It also discusses Django's modules, like forms, administration, caching, and signals. An example project is provided to demonstrate starting a project, adding an app with a model, and exploring the admin interface.
ºÝºÝߣs from our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
Django is a Python web framework that encourages rapid development and clean design. It includes an ORM, URL routing, templates, internationalization support, caching, authentication, and an admin interface. Django uses the MVT architecture, with Models handling data, Views returning responses, and Templates rendering output. Requests go through the URL dispatcher to Views, which can retrieve Model data and pass it to Templates to generate responses. The framework provides tools to define Models, URLs, Views and Templates to build applications.
Sanjay Rathore presents an introduction to the Django web framework. He discusses key features of Django including rapid development, security, and scalability. He outlines the MVT (Model View Template) architecture, describing the roles of each component. He also demonstrates how to install Django, set up a virtual environment, and build a basic MVT application with URL routing and templates. Pros of Django include its Python-based code, database management, and security, while cons are its potential heaviness for small projects.
- The document describes the process of setting up a Django web application project called Learning Log. This includes creating a virtual environment, installing Django, creating a Django project and app, defining models, registering models with the admin site, adding data to the models, and making initial pages by defining a URL pattern and view function. The goal of the Learning Log project is to allow users to log topics they are interested in and make journal entries about each topic.
This document introduces Flask, a Python framework for building web applications. It explains that Flask uses Python decorators to define routes for the web server. Before writing a Flask application, the reader is instructed to install Python, pip, virtualenv, and Flask within a new project directory. The basics of writing a Flask application are then covered, including running the application and defining routes to return responses. The document ends with quiz questions and resources for learning more about Flask.
This document provides an overview of Flask, a microframework for Python. It discusses that Flask is easy to code and configure, extensible via extensions, and uses Jinja2 templating and SQLAlchemy ORM. It then provides a step-by-step guide to setting up a Flask application, including creating a virtualenv, basic routing, models, forms, templates, and views. Configuration and running the application are also covered at a high level.
This document provides an overview of the Django web framework. It begins with definitions of Django and the MTV architectural pattern it follows. It then explains the differences between MTV and traditional MVC. Models, templates, and views are described as the core components of MTV. The document outlines Django's installation process and project structure. It also discusses Django's database API and advantages such as ORM support, multilingualism, and administration interfaces. Popular websites that use Django are listed before the document concludes by praising Django's security features and database API.
The document provides an overview of working with JSON (JavaScript Object Notation). It introduces JSON, explaining its need and comparing it to XML. It describes JSON syntax rules, data types, objects, and arrays. It discusses how JSON uses JavaScript syntax and can be used in files. The document also covers JSON security concerns, using JSON with JavaScript functions, client-side frameworks, server-side frameworks, replacing XML with JSON, and parsing and AJAX with JSON and jQuery.
Django Tutorial | Django Web Development With Python | Django Training and Ce...Edureka!
?
( Python Django Training - https://www.edureka.co/python-django )
This Edureka ¡°Django Tutorial" introduces you to django along with a practical to create web application using python web framework. This video helps you to learn following topics:
1. Why Django framework?
2. What is Django?
3. Architecture: MVC-MVT Pattern
4. Hands On: Getting started with Django
5. Building blocks of Django
6. Project: A web application
This document provides an overview of Angular, including:
- Angular is a JavaScript framework used to build client-side applications with HTML. Code is written in TypeScript which compiles to JavaScript.
- Angular enhances HTML with directives, data binding, and dependency injection. It follows an MVC architecture internally.
- Components are the basic building blocks of Angular applications. Modules contain components and services. Services contain reusable business logic.
- The document discusses Angular concepts like modules, components, data binding, services, routing and forms. It provides examples of creating a sample login/welcome application in Angular.
This document provides an overview and introduction to Django Girls training on Django and web development. It covers the following key points:
- Django is a Python web framework that makes building websites faster and easier. It includes components that handle common tasks like database access.
- The tutorial will teach you to build a simple blog application. By the end, you will have a working blog that you can deploy for others to see online.
- It introduces important concepts like how the internet works, what the command line is, what Django is, why frameworks are useful, and how requests are handled in Django.
- It provides instructions on installing Django and setting up a development environment with a virtual environment and SQLite database.
Server-side programming involves writing code that runs on a web server using languages like Java, PHP, and C#. It processes user input, displays pages, structures applications, and interacts with storage. Client-side programming writes code that runs in the user's browser using JavaScript. In a typical interaction, a user's browser requests a page from a server, which processes the request and returns the page which is then rendered in the browser. Common server-side programming languages and frameworks include PHP, Python, and ASP.Net. Web pages can be static with fixed HTML content or dynamic where the content changes based on server-side processing.
This document introduces Django, an open-source Python web framework. It describes Django's key features like rapid development, reusable apps, an admin interface, and templates. It explains Django's model-view-template architecture, including models for defining data, views for business logic, URLs for routing, and templates for presentation. It provides examples of defining a blog application in Django with models, views, URLs, and templates.
The document describes the Model-View-Controller (MVC) software architectural pattern. MVC separates an application into three main components: the model, the view, and the controller. The model manages the application's data and business logic. The view displays the model's information. The controller interprets inputs from the user and updates the model and/or view accordingly. This separation of concerns makes the application modular, reusable, and maintainable.
This document provides an overview of key concepts in Django including: installation and setup using pip and virtual environments; the built-in admin interface; the model-view-template pattern; handling URLs and routes; middleware; static files; database migrations; model forms; and Django forms. It explains that Django is a Python web framework that handles common web development tasks to allow developers to focus on application code.
PHP is a server-side scripting language used to create dynamic web pages. It allows embedding PHP code within HTML pages and interacting with databases. Key elements of PHP include variables, control structures, functions, and sessions. Sessions store user data on the server instead of the client to avoid cookies and allow tracking users across multiple pages.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
( ** Python Certification Training: https://www.edureka.co/python ** )
This Edureka PPT on Tkinter tutorial covers all the basic aspects of creating and making use of your own simple Graphical User Interface (GUI) using Python. It establishes all of the concepts needed to get started with building your own user interfaces while coding in Python.
This document provides an introduction and overview of REST APIs. It defines REST as an architectural style based on web standards like HTTP that defines resources that are accessed via common operations like GET, PUT, POST, and DELETE. It outlines best practices for REST API design, including using nouns in URIs, plural resource names, GET for retrieval only, HTTP status codes, and versioning. It also covers concepts like filtering, sorting, paging, and common queries.
The document discusses the Django web application framework. It describes Django as a high-level Python framework that encourages rapid development and clean design. It outlines Django's architecture, which follows an MVT pattern with models, views, templates, and a URL dispatcher. It also discusses Django's modules, like forms, administration, caching, and signals. An example project is provided to demonstrate starting a project, adding an app with a model, and exploring the admin interface.
This document provides an introduction and overview of the Django web framework. It discusses topics such as the MVC architectural pattern, Django's implementation of MTV instead of MVC, key features like the ORM and built-in web server, the Django architecture and design philosophies of loose coupling and DRY principles. The document also covers the project structure, settings configuration, and URL dispatcher in Django.
Kivy - Python UI Library for Any PlatformSaurav Singhi
?
The document discusses how to set up and use Kivy, an open source Python framework for developing multi-touch applications. It covers installing Kivy, basic components like App and widgets, different layouts, making a simple "Hello World" app, using the kv language to separate design from code, and packaging the app into an Android application.
Building Pluggable Web Applications using DjangoLakshman Prasad
?
The document discusses building pluggable web applications using Django. It provides an overview of Django's features like the admin interface, generic views, testing tools, sessions, authentication, caching, internationalization, and CSRF protection. It also discusses writing reusable Django apps, common conventions like using template tags and signals, and popular reusable apps like Pinax and django-mingus that provide features like user profiles, messaging, blogs, and wikis.
There's plenty of material (documentation, blogs, books) out there that'll help
you write a site using Django... but then what? You've still got to test,
deploy, monitor, and tune the site; failure at deployment time means all your
beautiful code is for naught.
Rami Sayar presented on advanced Django architecture techniques for scaling Django applications in production environments. He discussed load balancing Django across multiple servers using solutions like HAProxy. He also covered caching with Varnish to improve performance, and using Redis or Memcached for caching. Finally, he discussed asynchronous task queues like Celery for processing tasks outside the request-response cycle.
The Django Web Application Framework is a Python-based web framework that provides tools and features for building web applications quickly and easily. It includes components for HTTP handling, URL routing, templating, database access, forms, internationalization, and an optional administrative interface. Django emphasizes clean and pragmatic design with philosophy of "batteries included but removable".
Django is a high-level Python web framework that encourages rapid development and clean design. It includes features like an object-relational mapper, automatic admin interface, URL dispatcher, template system, cache system, internationalization support, form handling, and more. Django reads metadata from models to generate a production-ready admin interface for adding and updating content. Views interact with models to generate querysets for templates to display as responses. The framework handles common tasks to allow developers to focus on project-specific code.
This document provides an overview and introduction to web programming using the Python Django web framework. It discusses what Django is and its key features like pluggable apps, an object-relational mapper for databases, an automatic admin interface, templates, and URL structure. The core components of models, views, templates, and URLs are explained. Models are used to store and retrieve data from databases. Views are functions that generate web pages by utilizing models and templates. Templates contain tags to dynamically output content. URLs are mapped to views using a configuration file. The document also covers forms, the admin interface, and provides examples throughout.
This document provides an overview and introduction to the Django web framework. It discusses that Django is a free and open-source Python framework that encourages rapid development and clean design. It follows the MVC pattern and includes an ORM, automatic admin interface, templating system, and more. The document then discusses starting a Django project, creating apps, defining URLs and views, using templates, and includes an appendix on additional topics like models and sending mail.
GDG Addis - An Introduction to Django and App EngineYared Ayalew
?
This document provides an overview of developing and deploying Django applications to Google App Engine. It begins with an introduction to Django and how to set up a Django development environment using virtualenv and pip. It then covers common Django components like models, views, templates, URLs and forms. It concludes with a brief discussion of deploying Django applications to App Engine. The key topics covered include setting up a virtual environment for Django development, the model-view-template architecture of Django, and using Django tools and components to build an application that can be deployed to App Engine.
This document summarizes key aspects of using the Django web framework:
1) It describes how to start a new Django project, create apps, define models, migrate the database, and run the development server.
2) It explains how to build templates, map URLs, write views, and use templates to display data on pages.
3) It covers template inheritance, using parameters from URLs in views, and accessing context data from views in templates.
This document provides instructions for setting up a Django development environment and creating a basic Django project with an app. It covers installing Python and Pipenv, creating a virtual environment, installing Django, generating a project scaffold, creating an app, configuring URLs and templates, making migrations and running the development server. It also discusses Django templates, forms, models, views and generic views at a high level.
Django is a Python web framework that allows for rapid development of web applications. It includes features like an object relational mapper, template language, form handling, and more. To use Django, you create models to define the application's data structures, views to handle requests and return responses, and URLs to map requests to views. The Django admin interface provides a quick way to manage models in the database. Overall, Django aims to relieve web developers of low-level tasks so they can focus on writing application logic.
Django is a Python web framework that makes building websites easier. It uses the MVC pattern with models representing the database, views handling requests and responses, and templates rendering HTML. Django generates URLs, handles forms and validation, and includes an admin interface. It removes redundancy through its template inheritance system and object-relational mapper that allows interacting with databases through Python objects.
Python Expense Tracker Project with Source Code.pdfabhishekdf3
?
Inflow and Outflow record of money can be easily kept with the help of expense tracker. It helps to manage finances. In this project, we will develop an expense tracker that will track our expenses. Let¡¯s start developing the project.
Learn more at :- https://techvidvan.com/courses/python-course-hindi/
This document provides an overview of Django, a popular Python web framework. It discusses key features of Django including its MVT architecture, ORM, admin interface, and template system. It also covers common Django practices like project structure, apps, settings, models, views, URLs, forms, and using the Django REST framework to build APIs. Major sections include installation, configuration, building models, views, templates, and forms.
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimMir Nazim
?
Django is a high-level Python web framework that abstracts away common problems of web development. It provides shortcuts for building dynamic websites and includes features like URL mapping, templates, forms handling, database access, and more. The document provides an overview of Django and walks through building a sample polls application to demonstrate key aspects like models, views, templates, and the admin interface.
This is a small introduction to the django framework I did for fellow engineers at Anevia. It touches on many of the major concepts and core features of django and gives a typical workflow built about the example of a minimalist blog engine.
An Introduction to Django Web FrameworkDavid Gibbons
?
Django is a Python web framework created in 2003 that encourages rapid development and clean, pragmatic design. It uses a Model-View-Controller architectural pattern with models representing database tables, views containing logic, and templates for user-facing content. Some key features include automatically generated admin interfaces, URL routing, forms handling, internationalization support, and various utilities like static file management. Django is highly customizable and promotes code reuse and modularity through applications that can be combined for a project. It is one of the most popular web frameworks and powers many major sites today.
A Web Framework that shortens the Time it takes to develop software in at least an Order of Magnitude. while also tremendously minimizing Effort Pain, Time waste, Complexity, Cost of change & more
Django is a Python-based web framework that follows the MTV (Model-Template-View) design pattern. It allows developers to create dynamic websites and web applications by handling common tasks like database access, session management, and rendering templates. The document outlines how to create a Django project and app, configure settings like the database, and link views to URLs to handle requests and return responses.
This document summarizes a hands-on session on the Django web framework. It introduces Django's architecture, installation process, basic usage including templates, models, and the ORM. Key features covered include generating static and dynamic pages, creating and querying database models, and rendering data in templates. The session demonstrates setting up a basic Django project and application with models, views, URLs and templates to display hard-coded and database content.
Django is a Python-based MVC web framework. It follows an MTV pattern where the Model represents the business logic and database, the Template displays data, and the View connects Models and Templates by handling requests and returning responses. The presentation discusses why use Python and Django, what MVC is, and each component of MTV in Django - Models define database schemas, Views handle requests and return responses using Templates, and the framework handles common tasks like authentication, internationalization, and more. It also introduces Django Admin which automatically generates interfaces to manage database objects.
Django is a Python web framework that supports rapid development of pragmatic web applications. It allows defining models, views, URLs and templates to structure the application logically. Models define the database schema using Python classes. Views handle requests and return responses like HTML. Templates define presentation logic separately. Django provides a full-featured admin interface and forms to manage data. It aims to strike a balance between high-level features and low-level flexibility.
Django is a Python web framework that encourages rapid development and clean, pragmatic design. It uses the MTV (Model Template View) pattern rather than MVC. Django features an ORM, form handling, template system and admin interface. To set up a Django project, you create a project directory, install Django, add apps, set up models and URLs, and develop templates and views. Django promotes loose coupling, DRY principles and writing minimal code.
3. Outline
ª« What Is Django?
ª« Project Structure
ª« Data Handling
ª« The Admin Interface
ª« Django Forms
ª« Views
ª« Templates
4. What Is Django?
ª« High-level framework for rapid web development
ª« Complete stack of tools
ª« Data modelled with Python classes
ª« Production-ready data admin interface, generated dynamically
ª« Elegant system for mapping URLs to Python code
ª« Generic views¡¯ to handle common requests
ª« Clean, powerful template language
ª« Components for user authentication, form handling, caching . . .
5. Creating Projects & Apps
ª« Creating a project:
django-admin.py startproject mysite
ª« Creating an app within a project directory:
cd mysite
./manage.py startapp poll
6. Project Structure
ª« A Python package on your PYTHONPATH
ª« Holds project-wide settings in settings.py
ª« Holds a URL configuration (URLconf) in urls.py
ª« Contains or references one or more apps
7. App
ª« A Python package on your PYTHONPATH
(typically created as a subpackage of the project itself)
ª« May contain data models in models.py
ª« May contain views in views.py
ª« May have its own URL configuration in urls.py
8. Up & Running
ª« Set PYTHONPATH to include parent of your project directory
ª« Define new environment variable DJANGO_SETTINGS_MODULE,
setting it to project settings (mysite.settings)
ª« 3 Try running the development server:
/manage.py runserver
9. Creating The Database
ª« Create database polls in youe database
ª« Sync installed apps with database:
./manage.py syncdb
12. Create Models
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
13. The Data Model
ª« A description of database layout, as a Python class
ª« Normally represents one database table
ª« Has fields that map onto columns of the table
ª« Many built-in field types
ª« CharField, TextField
ª« IntegerField, FloatField, DecimalField
ª« DateField, DateTimeField, TimeField
ª« EmailField, URLField
ª« ForeignKey . . .
15. Registering Models in Admin
ª« In admin.py in the Poll app:
from django.contrib import admin
from mysite.polls.models import Poll
admin.site.register(Poll)
16. In urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(/slideshow/django-ppt/18985404/r&)),
)
17. Generic Views
ª« Provide ready-made logic for many common tasks:
ª« Issuing a redirect
ª« Displaying a paginated list of objects
ª« Displaying a ¡®detail¡¯ page for a single object
ª« Yearly, monthly or daily listing of date-based
objects
ª« ¡®Latest items¡¯ page for date-based objects
ª« Object creation, updating, deletion (with/without
authorisation)
18. Generic Views Example
ª« views.py
def index(request):
return HttpResponse("Hello, world. You're at the poll index.")
ª« Url.py
from django.conf.urls.defaults import *
from polls import views
urlpatterns = patterns('',
url(/slideshow/django-ppt/18985404/r&)
)
ª« Main URL.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(/slideshow/django-ppt/18985404/r&)),
url(/slideshow/django-ppt/18985404/r&)),
)
19. Creating & Saving Objects
ª« Invoke constructor and call save method:
ª« call create method of Club model manager:
poll = Poll(question='what is your DOB? ', year='1986)
poll.save()
Poll.objects.create(question='what is your DOB? ', year='1986)
20. View Function
ª« Takes an HTTPRequest object as a parameter
ª« Returns an HTTPResponse object to caller
ª« Is associated with a particular URL via the URLconf
21. HTTP Response
from datetime import date
from django.http import HttpResponse
def today(request):
html = '<html><body><h2>%s</h2></body></html>' % date.today()
return HttpResponse(html)
from django.shortcuts import render_to_response
From mysite.polls.models import Poll
def poll_details(request):
today = date.today()
poll_data = Poll.objects.all()
return render_to_response('clubs.html', locals(), context_instance =
RequestContext(request))
22. Templates
ª« Text files containing
ª« Variables, replaced by values when the template
is rendered[
ª« {{ today }}
ª« Filters that modify how values are displayed
ª« {{ today|date:"D d M Y" }}
ª« Tags that control the logic of the rendering
process
ª« {% if name == "nick" %}
ª« <p>Hello, Nick!</p>
ª« {% else %}
ª« <p>Who are you?</p>
ª« {% endif %}
23. Template Example
settings.py
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
templates/club/club_list.html
{% extends "base.html" %}
{% block title %}Clubs{% endblock %}
{% block content %}
<h1>Clubs</h1>
<ol>
{% for club in clubs %}
<li>{{ club }}</li>
{% endfor %}
</ol>
{% endblock %}
24. Django Forms
ª« A collection of fields that knows how to validate itself and display
itself as HTML.
ª« Display an HTML form with automatically generated form widgets.
ª« Check submitted data against a set of validation rules.
ª« Redisplay a form in the case of validation errors.
ª« Convert submitted form data to the relevant Python data types.
25. Django Model Forms
from django.forms import ModelForm
import mysite.polls.models import Poll
class PollForm(ModelForm):
class Meta:
model = Pole
32. Summary
ª« We have shown you
ª« The structure of a Django project
ª« How models represent data in Django applications
ª« How data can be stored and queried via model
instances
ª« How data can be managed through a dynamic
admin interface
ª« How functionality is represent by views, each
associated
with URLs that match a given pattern
ª« How views render a response using a template