Table of Contents

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Code in Action

Download the color images

Conventions used

Get in touch

Share Your Thoughts

Part 1 – Starting a Project

Chapter 1: Undertaking a Colossal Project

Technical requirements

Building an enterprise

Reasons to choose enterprise-level applications

Types of enterprise systems

Why Python/Django?

Types of APIs

Designing and planning

Requirements gathering

Visualization and interpretation

Hosting and deployment

Creating and configuring a Heroku plan

Configuring Heroku environments

Custom repositories

Advanced deployment

Domain Name System

Summary

Chapter 2: Project Configuration

Technical requirements

Choosing development tools

Text editors

Integrated development environments

Starting a project

Using the IDE

Using the command line

Creating a virtual environment

Configuring the requirements.txt file(s)

Using the IDE

Using the command line

Project configuration

Django settings.py file

Creating an environment file

Creating a Procfile

Django static files

Django media files

Creating a .gitignore file

Creating a Django app

Using basic database settings

SQLite

MySQL

MariaDB

Oracle

SQL Server

PostgreSQL

Preparing PostgreSQL for Heroku

Installing PostgreSQL

Using the PgAdmin tool

Environment connection settings

Building initial table structures

Remote data migrations

Heroku database push/pull operations

Summary

Chapter 3: Models, Relations, and Inheritance

Technical requirements

Preparing for this chapter

Writing model classes

Standard field types

Third-party field types

Model field validators

Working with model field relationships

Field arguments

Field type – ForeignKey

Field type – ManyToManyField

Mutable versus immutable objects

Using the Meta subclass

Meta options – verbose_name and verbose_name_plural

Meta option – ordering

Meta option – indexes

Meta option – db_table

Customizing models

Writing methods

Decorators

Extending models

Extending basic model classes

Extending the Django User model

Using the Django shell

Running basic Python scripts

Generating a SECRET_KEY variable

Saving data

Loading the chapter_3 data fixture

Performing queries

Model method – all()

Model method – get()

Model method – filter()

Aggregates

Writing model managers

Summary

Part 2 – Django Components

Chapter 4: URLs, Views, and Templates

Technical requirements

Preparing for this chapter

Configuring URL patterns

Basic path functions

Redirecting patterns

Using path converters

Mapping URL patterns

Using simple views

Using kwargs in views

Working with conditional responses

Linking models to views and templates

Resolving URLs

Naming URL patterns

Using the reverse() function

Using the {% url %} template tag

Processing trailing slashes

Resolving absolute URLs

Creating a context processor

From the request object

From within a model class

Working with complex views

Class-based views

Extending class-based views

Asynchronous views

Working with templates

Template tags

Template filters

Custom tags and filters

Error page templates

Summary

Chapter 5: Django Forms

Technical requirements

Preparing for this chapter

Types of forms

Form class – Form

Form class – ModelForm

Using form fields

Common field arguments

Field widgets

Field validators

Cleaning forms

Method – clean_{{ your_field_name }}()

Method – clean()

Creating custom form fields

Field class – Field

Using a custom field

Working with form views

View class – FormView

HTTP request methods

Rendering forms in templates

Render form – as_p

Render form – as_table

Render form – as_ul

Render form – using template_name

Render demo

Linking a model to a form

View class – CreateView

View class – UpdateView

Adding inline formsets

Formset function – formset_factory

Using inline formsets in the view class

Rendering inline formsets in the template

Dynamic inline formsets

Summary

Chapter 6: Exploring the Django Admin Site

Technical requirements

Preparing for this chapter

Using the Django admin site

Activating the Django admin site

Logging into the Django admin site

Writing admin classes

Registering models

Configuring admin class options

Changelist view-related options

Change/add view-related options

Add view-related options

Adding admin class methods

Method – get_form()

Method – save_model()

Method – delete_model()

Writing custom admin form classes

Initializing an admin form

Using the Django authentication system

Adding a seller

Granting permissions

Permission groups

Summary

Chapter 7: Working with Messages, Email Notifications, and PDF Reports

Technical requirements

Preparing for this chapter

Creating a Mailtrap account

Using the Django messages framework

Enabling the Django messages framework

Creating a message

Displaying messages

Configuring email notifications

As plain text emails

As HTML emails

As HTML emails with a plain text alternative

With file attachments

That fail silently

Writing custom email templates

For plain text emails

For HTML emails

Providing template context

Generating PDF reports

As template-based PDFs

Adding context

Summary

Part 3 – Advanced Django Components

Chapter 8: Working with the Django REST Framework

Technical requirements

Preparing for this chapter

Installing the Django REST framework

Serializing objects

The serializer classes

The viewset classes

Using URL routers

Using the Browsable API

Building SPA-like pages

Creating the view

Building the template

Writing the JavaScript

Mapping the URL pattern

First demo

Writing custom API endpoints

Creating the view

Building the template

Modifying the JavaScript

Mapping the URL pattern

Second demo

Authenticating with tokens

Project configuration

Creating the view

Building the template

Modifying the JavaScript

Mapping the URL pattern

Third demo

Summary

Chapter 9: Django Testing

Technical requirements

Preparing for this chapter

Understanding automated testing in Django

Getting started with unit testing

Basic unit test script

Testing Django models

Testing HTTP view requests

Testing method-based views

Testing class-based views

Testing authenticated view requests

Using the Client() class

Testing Django REST API endpoints

Creating an object test case

Updating an object test case

Using the DjDT

Installing the DjDT

How to use the DjDT

Summary

Chapter 10: Database Management

Technical requirements

Preparing for this chapter

Exporting data into a data fixture

Using the dumpdata command

Importing data from a data fixture

Using the importdata command

Using the select_related() method

Creating the view

Building the template

Mapping the URL pattern

First demo

Using the prefetch_related() method

Vehicles view

Sellers view

Using the Prefetch() class

Modifying the view

Modifying the template

Fourth demo

Summary

Why subscribe?

Other Books You May Enjoy

Share Your Thoughts

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.64.248