liveBook · Manning

CRUD

As explained in Django in Action

CRUD is the set of data operations consisting of create, read, update, and delete.

CRUD names the four routine operations performed on data: create, read, update, and delete. In Django Admin, registering a model automatically provides pages for these operations. section 5.1.3

A Django Admin model typically exposes:

  • Listing and Change pages for reading objects and updating their fields. section 5.1.3
  • Add and Delete pages for creating and removing objects. section 5.1.3
  • A registered ModelAdmin class connected to the application’s model. section 5.1.3

Registering a Musician model

Define MusicianAdmin as a subclass of admin.ModelAdmin and register it with Musician. Even an empty class body provides the default CRUD pages. section 5.1.3

Listing 5.1 The MusicianAdmin class
# RiffMates/bands/admin.py
from django.contrib import admin

from bands.models import Musician  #1

@admin.register(Musician)  #2
class MusicianAdmin(admin.ModelAdmin): #3
    pass  #4

Inspect the compact MusicianAdmin registration pattern, including the model import, decorator, subclass, and empty body. section 5.1.3

How Django in Action covers it

How deep it goes
Explains each operation through Django Admin screens and registration, without detailing custom page implementation.
Examples
Uses a Musician model, MusicianAdmin registration, listing, change, add, and delete pages.
What it assumes
Assumes a Django model and app admin.py file, while teaching model registration from the basic class structure.
What you can do after
Operate/configure Django Admin CRUD pages by registering a model with a ModelAdmin class.
How it connects
Connects CRUD with Django Admin, models, ModelAdmin classes, model registration, and ORM objects.

Also explained in

Compare how 11 books explain CRUD →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.