Learning Django Web Development (Python)

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This book is for web developers who want to get started with Django for web development. Basic knowledge of Python programming is required but no knowledge of Django is expected.

Author(s): Ratan Kumar; Sanjeev Jaiswal
Year: 2015

Language: English
Pages: 336

Learning Django Web Development
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction to Django
Why web development in the first place?
What has changed in web development
The MVC pattern in web development
Multilingual support
Why Django?
Inside Django
Django is mature
Batteries included
Tight integration between the component and modular framework
Object-relational mapper
Clean URL design
Automatic administration interface
Advanced development environment
What's new in Django 1.6 and 1.7
Supported databases
What you will learn using this book
Summary
2. Getting Started
Installing the required software
Installing Python
Installing Python on Windows
Installing Python on Unix/Linux
Installing Python on Mac OS X
Installing virtualenv
Installing Django
Django compatibility with operating systems – Windows versus Linux
Installing Django on Windows
Installing Django on Unix/Linux and Mac OS X
Installing a database system
Creating your first project
Creating an empty project
Setting up the database
Launching the development server
Summary
3. Code Style in Django
Django coding style
Understanding indentation in Python
Doing indentation right – do we need four spaces per indentation level?
The importance of blank lines
Importing a package
Grouping imported packages
Naming conventions in Python/Django
Using IDE for faster development
Setting up your project with the Sublime text editor
Setting up the PyCharm IDE
The Django project structure
Best practices – using version control
Git – the latest and most popular version control tool
How Git works
Setting up your Git
Branching in Git
Setting up the database
Launching the development server
Faster web development
Minimal Bootstrap
The Django way
Manual installation of Bootstrap
Summary
4. Building an Application Like Twitter
A word about Django terminology
Setting up a basic template application
Creating a virtual environment
Installing Django
Creating Django's template structure of the project
Setting up the basic Twitter Bootstrap for the application
URLs and views – creating the main page
Introduction to class-based views
Django settings for the mytweets project
Putting it all together – generating user pages
Familiarization with the Django models
Relationships in models
Many-to-one relationships
One-to-one relationships
Many-to-many relationships
Models – designing an initial database schema
Django's user objects
Creating a URL
Templates – creating a template for the Main Page
Summary
5. Introducing Hashtags
The hashtag data model
Django forms
Designing the tweet post form
Creating a tag page
Summary
6. Enhancing the User Interface with AJAX
AJAX and its advantages
Using an AJAX framework in Django
Using the open source jQuery framework
The jQuery JavaScript framework
Element selectors
jQuery methods
Hiding and showing elements
Accessing CSS properties and HTML attributes
Manipulating HTML documents
Traversing the document tree
Handling events
Sending AJAX requests
What next?
Implementing the searching of tweets
Implementing a searching
Implementing the live searching of tweets
Editing a tweet in place without loading a separate page
Implementing bookmark editing
Implementing in-place editing of bookmarks
Autocompletion of hashtags while submitting a tweet
Summary
7. Following and Commenting
Letting users follow another user
The UserFollowers data model
The user login model
Adding or removing the follower
Displaying the most followed user
Summary
8. Creating an Administration Interface
Customizing the administration interface
Customizing listing pages
Overriding administration templates
Users, groups, and permissions
User permissions
Group permissions
Using permissions in views
Organizing content into pages – pagination
Summary
9. Extending and Deploying
Sending invitation e-mails to friends
The invitation data model
Handling activation links
Internationalization (i18n) – offering the site in multiple languages
Marking strings as translatable
Creating translation files
Enabling and configuring the i18n system
Caching – improving the performance of your site during high traffic
Enabling caching
Configuring caching
Caching the whole site
Caching specific views
Unit testing – automating the process of testing your application
The test client
Testing the registration view
Deploying Django
The production web server
Summary
10. Extending Django
Custom template tags and filters
Class-based generic views
Contributed sub-frameworks
Flatpages
Humanize
Sitemap
Cross-site request forgery protection
The message system
The subscription system
User scores
Summary
11. Database Connectivity
SQL versus NoSQL
SQL databases
MySQL – open source
PostgreSQL
NoSQL databases
MongoDB
CouchDB
Redis
Setting up a database system
Setting up MySQL
Installing MySQL in Linux – Debian
Installing the MySQL plugin for Python
Migration and the need for migration
The new features in Django migration
Backend support
How to do migrations?
How migrations know what to migrate
The migration file
Django with NoSQL
The single-page application project – URL shortener
MongoEngine
Connecting MongoDB with Django
Authentication in Django
Storing sessions
Summary
12. Using Third-party Packages
Diving into the world of open source
What is an open source software?
What's the difference between open source and other software?
Using SocialAuth in Django projects
How OAuth works
Implementing social OAuth
Creating a Twitter application
Building REST APIs in Django
Using Django Tastypie
Implementing a simple JSON API
Summary
13. The Art of Debugging
Logging
Debugging
The Django debug toolbar
Installing the Django debug toolbar
IPDB – interactive way of busting bugs
Summary
14. Deploying Django Projects
The production web server
The production database
Turning off the debug mode
Changing configuration variables
Setting error pages
Django on cloud
EC2
Google Compute Engine
The open hybrid cloud application platform by Red Hat
Heroku
Google Application Engine
Summary
15. What's Next?
AngularJS meets Django
Django search with Elasticsearch
Installing an Elasticsearch server
Communication between Elasticsearch and Django
Creating an Elasticsearch index
Feeding the index with data
Retrieving search results from the index
Summary
Index