Book description
From an idea to a prototype – a complete guide for web development with the Django framework
About This Book
Explore the best practices to develop applications of a superior quality with Django framework
Unravel the common problems of web development in Django
This course teaches you major Django functions and will help you improve your skills by developing models, forms, views, and templates
Experience the challenges of working on an end-to-end social network project
Who This Book Is For
Web developers who want to use modern Python-based web frameworks like Django to build powerful web applications. The course is mostly self-contained and introduces web development with Python to a reader who is familiar with web development concepts and can help him become an expert in this trade. It’s intended for all levels of web developers, both students and practitioners from novice to experts.
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
In Detail
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.
Style and approach
This course includes all the resources that will help you jump into the web development field with Django and learn how to make scalable and robust web applications. The aim is to create a smooth learning path that will teach you how to get started with the powerful Django framework and perform various web development techniques in depth. Through this comprehensive course, you'll learn web development with Django from scratch to finish!
Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.
Table of contents
-
Django: Web Development with Python
- Table of Contents
- Django: Web Development with Python
- Django: Web Development with Python
- Credits
- Preface
-
1. Module 1
- 1. Django's Position on the Web
- 2. Creating a Django Project
- 3. Hello World! with Django
- 4. Working with Templates
- 5. Working with Models
- 6. Getting a Model's Data with Querysets
- 7. Working with Django Forms
- 8. Raising Your Productivity with CBV
- 9. Using Sessions
- 10. The Authentication Module
- 11. Using AJAX with Django
- 12. Production with Django
- A. Cheatsheet
-
2. Module 2
-
1. 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
-
2. 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
-
3. 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
- 4. Templates and JavaScript
-
5. 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
- 6. Model Administration
- 7. Django CMS
-
8. 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
- 9. Data Import and Export
-
10. 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
-
11. 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
-
1. Getting Started with Django 1.8
-
3. Module 3
- 1. Django and Patterns
- 2. Application Design
- 3. Models
- 4. Views and URLs
- 5. Templates
- 6. Admin Interface
- 7. Forms
- 8. Dealing with Legacy Code
- 9. Testing and Debugging
- 10. Security
- 11. Production-ready
-
A. Python 2 versus Python 3
- But I still use Python 2.7!
-
Python 3
- Python 3 for Djangonauts
- Change all the __unicode__ methods into __str__
- All classes inherit from the object class
- Calling super() is easier
- Relative imports must be explicit
- HttpRequest and HttpResponse have str and bytes types
- Exception syntax changes and improvements
- Standard library reorganized
- New goodies
- Other changes
- Further information
- A. Bibliography
- Index
Product information
- Title: Django: Web Development with Python
- Author(s):
- Release date: August 2016
- Publisher(s): Packt Publishing
- ISBN: 9781787121386
You might also like
video
Advanced Web Development in Python with Django
More than 8 Hours of Video Instruction Overview Advanced Web Development in Python with Django LiveLessons …
book
Django 3 Web Development Cookbook - Fourth Edition
Practical recipes for building fast, robust, and secure web apps using Django 3 and Python Key …
video
Web Development in Python with Django: Building Backend Web Applications and APIs with Django
9+ Hours of Video Instruction Leverage Python and the Django web framework to develop applications quickly …
book
Web Development with Django
Learn how to create your own websites simply, safely, and quickly with Django by tackling practical …