liveBook · Manning

CreateModel

As explained in Django in Action

CreateModel is a Django migration operation that creates a model and its corresponding database table.

CreateModel is a Django migration operation that tells the migration system to create a model’s database table. It appears inside a Migration class’s operations list, alongside the model name and field definitions. section 10.1.1 section 10.6

A Promoter table

An initial migration for the Promoters app can contain migrations.CreateModel with name="Promoter" and fields for first_name and last_name. Django also includes an automatically created id field as a BigAutoField primary key. Running the migration turns this description into the model’s database table. section 10.1.1

How Django in Action covers it

How deep it goes
Defines the operation’s placement, model name, and fields, but does not detail Django’s table-creation internals.
Examples
Uses the Promoter model with first_name, last_name, and an automatically created BigAutoField id.
What it assumes
Assumes familiarity with Django models and fields while establishing Migration classes, operations, and dependency ordering.
What you can do after
Operate/configure migrations by recognizing how a model definition becomes a database-table creation operation.
How it connects
Connects Django migrations with models, database tables, fields, dependencies, and makemigrations.

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.