liveBook · Manning

Register()

As explained in Django in Action

register() is the Django Admin function or decorator that associates a model with an administrative configuration class.

register() connects a Django model to an administrative configuration class, making that model available in Django Admin. The configuration class inherits from admin.ModelAdmin. section 5.1.3

Registering a model provides:

  • CRUD pages for creating, reading, updating, and deleting model objects. section 5.1.3
  • A Listing page containing object links to Change pages, plus Add and Delete pages. section 5.1.3
  • A decorator form that keeps registration beside the ModelAdmin declaration. section 5.1.3

Registering Musician

In bands/admin.py: from django.contrib import admin from bands.models import Musician @admin.register(Musician) class MusicianAdmin(admin.ModelAdmin): pass When Django loads the app, it discovers admin.py, applies the decorator, and exposes Musician through the Admin interface. The empty class keeps the default CRUD behavior; custom administrative options can be added later. section 5.1.3

How Django in Action covers it

How deep it goes
Explains function and decorator forms, app loading, ModelAdmin inheritance, and resulting CRUD pages.
Examples
Demonstrates registering the Musician model with an empty MusicianAdmin class using decorator syntax.
What it assumes
Assumes a Django app with a model and admin.py, while introducing ModelAdmin inheritance and registration.
What you can do after
Configure Django Admin to expose a model through default create, read, update, and delete screens.
How it connects
Connects Django Admin with models, ModelAdmin classes, CRUD operations, and app loading.

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.