Django for APIs Cookbook
¶
Setup Python Project
Setup Repository
Create Python Virtual Environment
Setup Project Documentation with Sphynx
Using Markdown with Sphynx
Import Docs Into ReadTheDocs
Setup a Django Project
Pre-requisites
Guide code:
Install Django dependencies
Create a project directory
Use django-admin to start a new project
Run and preview the project
Custom Django User Model
Pre-requisites
Guide code:
Create
accounts
Django Application
Create the User Model
Migrate the database
Register User Model in Admin
Create Django Models for the Blog API
Pre-requisites
Guide code:
Setup Sphinx for Mermaid
Create E-R diagram for our Blog API
Create Posts App
Create Posts Model
Create Comments Model
Create Tags Model
Test Models with Pytest
Pre-requisites
Guide code:
Setup for Testing with Pytest
Test the
CustomUser
Model
Test the
Post
Model
Test the
Comment
Model
Test the
Tag
Model
Execute the test suite
REST API with Djangno Rest Rest Framework
Pre-requisites
Guide code:
Install Django Rest Framework
Create Model Serializers
Create Model ViewSets
Define URL Routing for the Posts Application
Add Posts Application URL Routes to the Project’s URL Routes
Explore the API
Create Tests for the
posts
application API
Questions
Further Reading
Finite State Machine (state transitions) with
django-fsm
Pre-requisites
Guide code:
Introduction
Install
django-fsm
Modify Post Model
Test the State Machine
Generate Statechart Diagram
Questions
Further Reading
Pytest
Specify ID or Name for pytest Parameter Set
Future Topics
Testing Models
Blog REST APIs
Swagger UI for the Blog API
Tags
Django data export and import
Better instrumentation for development and testing
Celery and Django
Pagination in DRF
VSCode
Filters
Model
Default value provider
Pre Commit Hooks
Other Topics
Pre-Commit Hooks
Django for APIs Cookbook
Navigation
Setup Python Project
Setup a Django Project
Custom Django User Model
Create Django Models for the Blog API
Test Models with Pytest
REST API with Djangno Rest Rest Framework
Finite State Machine (state transitions) with
django-fsm
Pytest
Future Topics
Related Topics
Documentation overview
Next:
Setup Python Project