Django: Web Development with Python

From an idea to a prototype – a complete guide for web development with the Django framework
Preview in Mapt

Django: Web Development with Python

Samuel Dauzon, Aidas Bendoraitis, Arun Ravindran

5 customer reviews
From an idea to a prototype – a complete guide for web development with the Django framework

Quick links: > What will you learn?> Table of content> Product reviews

Mapt Subscription
FREE
$29.99/m after trial
eBook
$47.60
RRP $67.99
Save 29%
Print + eBook
$84.99
RRP $84.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$47.60
$84.99
$29.99 p/m after trial
RRP $67.99
RRP $84.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Django: Web Development with Python Book Cover
Django: Web Development with Python
$ 67.99
$ 47.60
Mastering Django: Core Book Cover
Mastering Django: Core
$ 39.99
$ 28.00
Buy 2 for $35.00
Save $72.98
Add to Cart

Book Details

ISBN 139781787121386
Paperback717 pages

Book Description

Data science is hot right now, and the need for multitalented developers is greater than ever before. A basic grounding in building apps with a framework as minimalistic, powerful, and easy-to-learn as Django will be a useful skill to launch your career as an entrepreneur or web developer. Django is a web framework that was designed to strike a balance between rapid web development and high performance. This course will take you on a journey to become an efficient web developer thoroughly understanding the key concepts of Django framework. This learning path is divided into three modules. The course begins with basic concepts of the Django framework. The first module, Django Essentials, is like a practical guide, filled with many real-world examples to build highly effective Django web application. After getting familiar with core concepts of Django, it's time to practice your learning from the first module with the help of over 90 recipes available in this module. In the second module, Web Development with Django Cookbook, you'll learn varying complexities to help you create multilingual, responsive, and scalable websites with Django. By the end of this module, you will have a good understanding of the new features added to Django 1.8 and be an expert at web development processes.The next step is to discover the latest best practices and idioms in this rapidly evolving Django framework. This is what you'll be learning in our third module, Django Design Patterns and Best Practices. This module will teach you common design patterns to develop better Django code. By the end of the module, you will be able to leverage the Django framework to develop a fully functional web application with minimal effort.

Table of Contents

Chapter 1: Django's Position on the Web
From Web 1.0 to Web 2.0
What is Django?
The MVC framework
Why use Django?
Summary
Chapter 2: Creating a Django Project
Installing Python 3
Installing setuptools
Installing PIP
Installing Django
Starting your project with Django
Creating an application
Configuring the application
Summary
Chapter 3: Hello World! with Django
Routing in Django
Regular expressions
Creating our first URL
Creating our first view
Testing our application
Summary
Chapter 4: Working with Templates
Displaying Hello world! in a template
Injecting the data from the view to the template
Creating dynamic templates
Integrating variables in templates
Using filters
Creating DRY URLs
Extending the templates
Using static files in templates
Summary
Chapter 5: Working with Models
Databases and Django
Migrations with South
Creating simple models
The relationship between the models
Extending models
The admin module
Advanced usage of models
Summary
Chapter 6: Getting a Model's Data with Querysets
The persisting model's data on the database
Getting data from the database
Using the get parameter
Saving the foreign key
Updating records in the database
Deleting a record
Getting linked records
Advanced usage of the queryset
Summary
Chapter 7: Working with Django Forms
Adding a developer without using Django forms
Adding a developer with Django forms
The form based on a model
Advanced usage of Django forms
Summary
Chapter 8: Raising Your Productivity with CBV
The CreateView CBV
Working with ListView
The DetailView CBV
The UpdateView CBV
The DeleteView CBV
Going further by extending the CBV
Summary
Chapter 9: Using Sessions
Creating and getting session variables
About session security
Summary
Chapter 10: The Authentication Module
How to use the authentication module
Adding a user
Login and logout pages
Restricting access to the connected members
Summary
Chapter 11: Using AJAX with Django
Working with jQuery
jQuery basics
Working with AJAX in the task manager
Summary
Chapter 12: Production with Django
Completing the development
Selecting the physical server
Selecting the server software
Selecting the server database
Deploying the Django website
Installing Django, South, Gunicorn, and psycopg2
Summary
Chapter 13: Getting Started with Django 1.8
Introduction
Working with a virtual environment
Creating a project file structure
Handling project dependencies with pip
Making your code compatible with both Python 2.7 and Python 3
Including external dependencies in your project
Configuring settings for development, testing, staging, and production environments
Defining relative paths in the settings
Creating and including local settings
Setting up STATIC_URL dynamically for Subversion users
Setting up STATIC_URL dynamically for Git users
Setting UTF-8 as the default encoding for MySQL configuration
Setting the Subversion ignore property
Creating the Git ignore file
Deleting Python-compiled files
Respecting the import order in Python files
Creating app configuration
Defining overwritable app settings
Chapter 14: Database Structure
Introduction
Using model mixins
Creating a model mixin with URL-related methods
Creating a model mixin to handle creation and modification dates
Creating a model mixin to take care of meta tags
Creating a model mixin to handle generic relations
Handling multilingual fields
Using migrations
Switching from South migrations to Django migrations
Changing a foreign key to the many-to-many field
Chapter 15: Forms and Views
Introduction
Passing HttpRequest to the form
Utilizing the save method of the form
Uploading images
Creating a form layout with django-crispy-forms
Downloading authorized files
Filtering object lists
Managing paginated lists
Composing class-based views
Generating PDF documents
Implementing a multilingual search with Haystack
Chapter 16: Templates and JavaScript
Introduction
Arranging the base.html template
Including JavaScript settings
Using HTML5 data attributes
Opening object details in a modal dialog
Implementing a continuous scroll
Implementing the Like widget
Uploading images by Ajax
Chapter 17: Custom Template Filters and Tags
Introduction
Following conventions for your own template filters and tags
Creating a template filter to show how many days have passed since a post was published
Creating a template filter to extract the first media object
Creating a template filter to humanize URLs
Creating a template tag to include a template if it exists
Creating a template tag to load a QuerySet in a template
Creating a template tag to parse content as a template
Creating a template tag to modify request query parameters
Chapter 18: Model Administration
Introduction
Customizing columns on the change list page
Creating admin actions
Developing change list filters
Customizing default admin settings
Inserting a map into a change form
Chapter 19: Django CMS
Introduction
Creating templates for Django CMS
Structuring the page menu
Converting an app to a CMS app
Attaching your own navigation
Writing your own CMS plugin
Adding new fields to the CMS page
Chapter 20: Hierarchical Structures
Introduction
Creating hierarchical categories
Creating a category administration interface with django-mptt-admin
Creating a category administration interface with django-mptt-tree-editor
Rendering categories in a template
Using a single selection field to choose a category in forms
Using a checkbox list to choose multiple categories in forms
Chapter 21: Data Import and Export
Introduction
Importing data from a local CSV file
Importing data from a local Excel file
Importing data from an external JSON file
Importing data from an external XML file
Creating filterable RSS feeds
Using Tastypie to create API
Using Django REST framework to create API
Chapter 22: Bells and Whistles
Introduction
Using the Django shell
Using database query expressions
Monkey-patching the slugify() function for better internationalization support
Toggling the Debug Toolbar
Using ThreadLocalMiddleware
Caching the method return value
Using Memcached to cache Django views
Using signals to notify administrators about new entries
Checking for missing settings
Chapter 23: Testing and Deployment
Introduction
Testing pages with Selenium
Testing views with mock
Testing API created using Django REST framework
Releasing a reusable Django app
Getting detailed error reporting via e-mail
Deploying on Apache with mod_wsgi
Setting up cron jobs for regular tasks
Creating and using the Fabric deployment script
Chapter 24: Django and Patterns
How does Django work to?
What is a Pattern?
Patterns in this book
Best practices
Summary
Chapter 25: Application Design
How to gather requirements
Are you a story teller?
HTML mockups
Designing the application
Before starting the project
SuperBook – your mission, should you choose to accept it
Summary
Chapter 26: Models
M is bigger than V and C
The model hunt
Structural patterns
Retrieval patterns
Migrations
Summary
Chapter 27: Views and URLs
A view from the top
Class-based generic views
View mixins
Decorators
View patterns
Designing URLs
Summary
Chapter 28: Templates
Understanding Django's template language features
Organizing templates
Using Bootstrap
Template patterns
Summary
Chapter 29: Admin Interface
Using the admin interface
Enhancing models for the admin
Admin interface customizations
Protecting the admin
Summary
Chapter 30: Forms
How forms work
Displaying forms
Understanding CSRF
Form processing with Class-based views
Form patterns
Summary
Chapter 31: Dealing with Legacy Code
Finding the Django version
Where are the files? This is not PHP
Starting with urls.py
Jumping around the code
Understanding the code base
Incremental change or a full rewrite?
Write tests before making any changes
Legacy databases
Summary
Chapter 32: Testing and Debugging
Why write tests?
Test-driven development
Writing a test case
Mocking
Pattern – test fixtures and factories
Learning more about testing
Debugging
The print function
Logging
The Django Debug Toolbar
The Python debugger pdb
Other debuggers
Debugging Django templates
Summary
Chapter 33: Security
Cross-site scripting (XSS)
A handy security checklist
Summary
Chapter 34: Production-ready
Production environment
Hosting
Deployment tools
Monitoring
Performance
Summary

What You Will Learn

  • Use Django models to store information in the database and generate queries to access a database across models
  • Quickly develop web pages to create, read, update, and delete data from the model using class-based views
  • Generate very maintainable forms with Django
  • Import data from local sources and external web services as well as exporting your data to third parties
  • Deep dive into various aspects of Django from models and views to testing and deployment
  • Familiarize yourself with the various nuances of web development such as browser attacks and databases

Authors

Table of Contents

Chapter 1: Django's Position on the Web
From Web 1.0 to Web 2.0
What is Django?
The MVC framework
Why use Django?
Summary
Chapter 2: Creating a Django Project
Installing Python 3
Installing setuptools
Installing PIP
Installing Django
Starting your project with Django
Creating an application
Configuring the application
Summary
Chapter 3: Hello World! with Django
Routing in Django
Regular expressions
Creating our first URL
Creating our first view
Testing our application
Summary
Chapter 4: Working with Templates
Displaying Hello world! in a template
Injecting the data from the view to the template
Creating dynamic templates
Integrating variables in templates
Using filters
Creating DRY URLs
Extending the templates
Using static files in templates
Summary
Chapter 5: Working with Models
Databases and Django
Migrations with South
Creating simple models
The relationship between the models
Extending models
The admin module
Advanced usage of models
Summary
Chapter 6: Getting a Model's Data with Querysets
The persisting model's data on the database
Getting data from the database
Using the get parameter
Saving the foreign key
Updating records in the database
Deleting a record
Getting linked records
Advanced usage of the queryset
Summary
Chapter 7: Working with Django Forms
Adding a developer without using Django forms
Adding a developer with Django forms
The form based on a model
Advanced usage of Django forms
Summary
Chapter 8: Raising Your Productivity with CBV
The CreateView CBV
Working with ListView
The DetailView CBV
The UpdateView CBV
The DeleteView CBV
Going further by extending the CBV
Summary
Chapter 9: Using Sessions
Creating and getting session variables
About session security
Summary
Chapter 10: The Authentication Module
How to use the authentication module
Adding a user
Login and logout pages
Restricting access to the connected members
Summary
Chapter 11: Using AJAX with Django
Working with jQuery
jQuery basics
Working with AJAX in the task manager
Summary
Chapter 12: Production with Django
Completing the development
Selecting the physical server
Selecting the server software
Selecting the server database
Deploying the Django website
Installing Django, South, Gunicorn, and psycopg2
Summary
Chapter 13: Getting Started with Django 1.8
Introduction
Working with a virtual environment
Creating a project file structure
Handling project dependencies with pip
Making your code compatible with both Python 2.7 and Python 3
Including external dependencies in your project
Configuring settings for development, testing, staging, and production environments
Defining relative paths in the settings
Creating and including local settings
Setting up STATIC_URL dynamically for Subversion users
Setting up STATIC_URL dynamically for Git users
Setting UTF-8 as the default encoding for MySQL configuration
Setting the Subversion ignore property
Creating the Git ignore file
Deleting Python-compiled files
Respecting the import order in Python files
Creating app configuration
Defining overwritable app settings
Chapter 14: Database Structure
Introduction
Using model mixins
Creating a model mixin with URL-related methods
Creating a model mixin to handle creation and modification dates
Creating a model mixin to take care of meta tags
Creating a model mixin to handle generic relations
Handling multilingual fields
Using migrations
Switching from South migrations to Django migrations
Changing a foreign key to the many-to-many field
Chapter 15: Forms and Views
Introduction
Passing HttpRequest to the form
Utilizing the save method of the form
Uploading images
Creating a form layout with django-crispy-forms
Downloading authorized files
Filtering object lists
Managing paginated lists
Composing class-based views
Generating PDF documents
Implementing a multilingual search with Haystack
Chapter 16: Templates and JavaScript
Introduction
Arranging the base.html template
Including JavaScript settings
Using HTML5 data attributes
Opening object details in a modal dialog
Implementing a continuous scroll
Implementing the Like widget
Uploading images by Ajax
Chapter 17: Custom Template Filters and Tags
Introduction
Following conventions for your own template filters and tags
Creating a template filter to show how many days have passed since a post was published
Creating a template filter to extract the first media object
Creating a template filter to humanize URLs
Creating a template tag to include a template if it exists
Creating a template tag to load a QuerySet in a template
Creating a template tag to parse content as a template
Creating a template tag to modify request query parameters
Chapter 18: Model Administration
Introduction
Customizing columns on the change list page
Creating admin actions
Developing change list filters
Customizing default admin settings
Inserting a map into a change form
Chapter 19: Django CMS
Introduction
Creating templates for Django CMS
Structuring the page menu
Converting an app to a CMS app
Attaching your own navigation
Writing your own CMS plugin
Adding new fields to the CMS page
Chapter 20: Hierarchical Structures
Introduction
Creating hierarchical categories
Creating a category administration interface with django-mptt-admin
Creating a category administration interface with django-mptt-tree-editor
Rendering categories in a template
Using a single selection field to choose a category in forms
Using a checkbox list to choose multiple categories in forms
Chapter 21: Data Import and Export
Introduction
Importing data from a local CSV file
Importing data from a local Excel file
Importing data from an external JSON file
Importing data from an external XML file
Creating filterable RSS feeds
Using Tastypie to create API
Using Django REST framework to create API
Chapter 22: Bells and Whistles
Introduction
Using the Django shell
Using database query expressions
Monkey-patching the slugify() function for better internationalization support
Toggling the Debug Toolbar
Using ThreadLocalMiddleware
Caching the method return value
Using Memcached to cache Django views
Using signals to notify administrators about new entries
Checking for missing settings
Chapter 23: Testing and Deployment
Introduction
Testing pages with Selenium
Testing views with mock
Testing API created using Django REST framework
Releasing a reusable Django app
Getting detailed error reporting via e-mail
Deploying on Apache with mod_wsgi
Setting up cron jobs for regular tasks
Creating and using the Fabric deployment script
Chapter 24: Django and Patterns
How does Django work to?
What is a Pattern?
Patterns in this book
Best practices
Summary
Chapter 25: Application Design
How to gather requirements
Are you a story teller?
HTML mockups
Designing the application
Before starting the project
SuperBook – your mission, should you choose to accept it
Summary
Chapter 26: Models
M is bigger than V and C
The model hunt
Structural patterns
Retrieval patterns
Migrations
Summary
Chapter 27: Views and URLs
A view from the top
Class-based generic views
View mixins
Decorators
View patterns
Designing URLs
Summary
Chapter 28: Templates
Understanding Django's template language features
Organizing templates
Using Bootstrap
Template patterns
Summary
Chapter 29: Admin Interface
Using the admin interface
Enhancing models for the admin
Admin interface customizations
Protecting the admin
Summary
Chapter 30: Forms
How forms work
Displaying forms
Understanding CSRF
Form processing with Class-based views
Form patterns
Summary
Chapter 31: Dealing with Legacy Code
Finding the Django version
Where are the files? This is not PHP
Starting with urls.py
Jumping around the code
Understanding the code base
Incremental change or a full rewrite?
Write tests before making any changes
Legacy databases
Summary
Chapter 32: Testing and Debugging
Why write tests?
Test-driven development
Writing a test case
Mocking
Pattern – test fixtures and factories
Learning more about testing
Debugging
The print function
Logging
The Django Debug Toolbar
The Python debugger pdb
Other debuggers
Debugging Django templates
Summary
Chapter 33: Security
Cross-site scripting (XSS)
A handy security checklist
Summary
Chapter 34: Production-ready
Production environment
Hosting
Deployment tools
Monitoring
Performance
Summary

Book Details

ISBN 139781787121386
Paperback717 pages
Read More
From 5 reviews

Read More Reviews

Recommended for You

Mastering Django: Core Book Cover
Mastering Django: Core
$ 39.99
$ 28.00
Python: Master the Art of Design Patterns Book Cover
Python: Master the Art of Design Patterns
$ 67.99
$ 47.60
Modern Python Cookbook Book Cover
Modern Python Cookbook
$ 39.99
$ 28.00
Python: Real World Machine Learning Book Cover
Python: Real World Machine Learning
$ 71.99
$ 50.40
Python: Penetration Testing for Developers Book Cover
Python: Penetration Testing for Developers
$ 67.99
$ 47.60
Python: Deeper Insights into Machine Learning Book Cover
Python: Deeper Insights into Machine Learning
$ 71.99
$ 50.40