万本电子书0元读

万本电子书0元读

顶部广告

Django 2 by Example电子书

售       价:¥

46人正在读 | 0人评论 6.2

作       者:Antonio Melé

出  版  社:Packt Publishing

出版时间:2018-05-31

字       数:59.5万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn Django 2.0 with four end-to-end projects About This Book ? Learn Django by building real-world web applications from scratch ? Develop powerful web applications quickly using the best coding practices ? Integrate other technologies into your application with clear, step-by-step explanations and comprehensive example code Who This Book Is For If you are a web developer who wants to see how to build professional sites with Django, this book is for you. You will need a basic knowledge of Python, HTML, and JavaScript, but you don't need to have worked with Django before. What You Will Learn ? Build practical, real-world web applications with Django ? Use Django with other technologies, such as Redis and Celery ? Develop pluggable Django applications ? Create advanced features, optimize your code, and use the cache framework ? Add internationalization to your Django projects ? Enhance your user experience using JavaScript and AJAX ? Add social features to your projects ? Build RESTful APIs for your applications In Detail If you want to learn about the entire process of developing professional web applications with Django, then this book is for you. This book will walk you through the creation of four professional Django projects, teaching you how to solve common problems and implement best practices. You will learn how to build a blog application, a social image-bookmarking website, an online shop, and an e-learning platform. The book will teach you how to enhance your applications with AJAX, create RESTful APIs, and set up a production environment for your Django projects. The book walks you through the creation of real-world applications, while solving common problems and implementing best practices. By the end of this book, you will have a deep understanding of Django and how to build advanced web applications Style and approach This easy-to-follow guide takes you through the process of building four different production-ready Django projects with a simple step-by-step approach.
目录展开

Title Page

Copyright and Credits

Django 2 by Example

Dedication

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

Building a Blog Application

Installing Django

Creating an isolated Python environment

Installing Django with pip

Creating your first project

Running the development server

Project settings

Projects and applications

Creating an application

Designing the blog data schema

Activating your application

Creating and applying migrations

Creating an administration site for your models

Creating a superuser

The Django administration site

Adding your models to the administration site

Customizing the way models are displayed

Working with QuerySet and managers

Creating objects

Updating objects

Retrieving objects

Using the filter() method

Using exclude()

Using order_by()

Deleting objects

When QuerySets are evaluated

Creating model managers

Building list and detail views

Creating list and detail views

Adding URL patterns for your views

Canonical URLs for models

Creating templates for your views

Adding pagination

Using class-based views

Summary

Enhancing Your Blog with Advanced Features

Sharing posts by email

Creating forms with Django

Handling forms in views

Sending emails with Django

Rendering forms in templates

Creating a comment system

Creating forms from models

Handling ModelForms in views

Adding comments to the post detail template

Adding the tagging functionality

Retrieving posts by similarity

Summary

Extending Your Blog Application

Creating custom template tags and filters

Creating custom template tags

Creating custom template filters

Adding a sitemap to your site

Creating feeds for your blog posts

Adding full-text search to your blog

Installing PostgreSQL

Simple search lookups

Searching against multiple fields

Building a search view

Stemming and ranking results

Weighting queries

Searching with trigram similarity

Other full-text search engines

Summary

Building a Social Website

Creating a social website project

Starting your social website project

Using the Django authentication framework

Creating a login view

Using Django authentication views

Login and logout views

Changing password views

Resetting password views

User registration and user profiles

User registration

Extending the user model

Using a custom user model

Using the messages framework

Building a custom authentication backend

Adding social authentication to your site

Authentication using Facebook

Authentication using Twitter

Authentication using Google

Summary

Sharing Content in Your Website

Creating an image bookmarking website

Building the image model

Creating many-to-many relationships

Registering the image model in the administration site

Posting content from other websites

Cleaning form fields

Overriding the save() method of a ModelForm

Building a bookmarklet with jQuery

Creating a detail view for images

Creating image thumbnails using sorl-thumbnail

Adding AJAX actions with jQuery

Loading jQuery

Cross-Site Request Forgery in AJAX requests

Performing AJAX requests with jQuery

Creating custom decorators for your views

Adding AJAX pagination to your list views

Summary

Tracking User Actions

Building a follower system

Creating many-to-many relationships with an intermediary model

Creating list and detail views for user profiles

Building an AJAX view to follow users

Building a generic activity stream application

Using the contenttypes framework

Adding generic relations to your models

Avoiding duplicate actions in the activity stream

Adding user actions to the activity stream

Displaying the activity stream

Optimizing QuerySets that involve related objects

Using select_related()

Using prefetch_related()

Creating templates for actions

Using signals for denormalizing counts

Working with signals

Application configuration classes

Using Redis for storing item views

Installing Redis

Using Redis with Python

Storing item views in Redis

Storing a ranking in Redis

Next steps with Redis

Summary

Building an Online Shop

Creating an online shop project

Creating product catalog models

Registering catalog models on the admin site

Building catalog views

Creating catalog templates

Building a shopping cart

Using Django sessions

Session settings

Session expiration

Storing shopping carts in sessions

Creating shopping cart views

Adding items to the cart

Building a template to display the cart

Adding products to the cart

Updating product quantities in the cart

Creating a context processor for the current cart

Context processors

Setting the cart into the request context

Registering customer orders

Creating order models

Including order models in the administration site

Creating customer orders

Launching asynchronous tasks with Celery

Installing Celery

Installing RabbitMQ

Adding Celery to your project

Adding asynchronous tasks to your application

Monitoring Celery

Summary

Managing Payments and Orders

Integrating a payment gateway

Creating a Braintree sandbox account

Installing the Braintree Python module

Integrating the payment gateway

Integrating Braintree using Hosted Fields

Testing payments

Going live

Exporting orders to CSV files

Adding custom actions to the administration site

Extending the admin site with custom views

Generating PDF invoices dynamically

Installing WeasyPrint

Creating a PDF template

Rendering PDF files

Sending PDF files by email

Summary

Extending Your Shop

Creating a coupon system

Building the coupon models

Applying a coupon to the shopping cart

Applying coupons to orders

Adding internationalization and localization

Internationalization with Django

Internationalization and localization settings

Internationalization management commands

How to add translations to a Django project

How Django determines the current language

Preparing our project for internationalization

Translating Python code

Standard translations

Lazy translations

Translations including variables

Plural forms in translations

Translating your own code

Translating templates

The {% trans %} template tag

The {% blocktrans %} template tag

Translating the shop templates

Using the Rosetta translation interface

Fuzzy translations

URL patterns for internationalization

Adding a language prefix to URL patterns

Translating URL patterns

Allowing users to switch language

Translating models with django-parler

Installing django-parler

Translating model fields

Integrating translations in the administration site

Creating migrations for model translations

Adapting views for translations

Format localization

Using django-localflavor to validate form fields

Building a recommendation engine

Recommending products based on previous purchases

Summary

Building an E-Learning Platform

Setting up the e-learning project

Building the course models

Registering the models in the administration site

Using fixtures to provide initial data for models

Creating models for diverse content

Using model inheritance

Abstract models

Multi-table model inheritance

Proxy models

Creating the content models

Creating custom model fields

Adding ordering to module and content objects

Creating a CMS

Adding an authentication system

Creating the authentication templates

Creating class-based views

Using mixins for class-based views

Working with groups and permissions

Restricting access to class-based views

Managing course modules and content

Using formsets for course modules

Adding content to course modules

Managing modules and contents

Reordering modules and contents

Using mixins from django-braces

Summary

Rendering and Caching Content

Displaying courses

Adding student registration

Creating a student registration view

Enrolling in courses

Accessing the course contents

Rendering different types of content

Using the cache framework

Available cache backends

Installing Memcached

Cache settings

Adding Memcached to your project

Monitoring Memcached

Cache levels

Using the low-level cache API

Caching based on dynamic data

Caching template fragments

Caching views

Using the per-site cache

Summary

Building an API

Building a RESTful API

Installing Django REST framework

Defining serializers

Understanding parsers and renderers

Building list and detail views

Creating nested serializers

Building custom views

Handling authentication

Adding permissions to views

Creating view sets and routers

Adding additional actions to view sets

Creating custom permissions

Serializing course contents

Summary

Going Live

Creating a production environment

Managing settings for multiple environments

Using PostgreSQL

Checking your project

Serving Django through WSGI

Installing uWSGI

Configuring uWSGI

Installing NGINX

The production environment

Configuring NGINX

Serving static and media assets

Securing connections with SSL

Creating an SSL certificate

Configuring NGINX to use SSL

Configuring our project for SSL

Creating a custom middleware

Creating a subdomain middleware

Serving multiple subdomains with NGINX

Implementing custom management commands

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部