QamoosTech
DatabasesORM and migrationsBeginnerDjangoPython

Model

PronunciationMOD-ul

Definition

In an ORM, a model is a class that describes a database table: its fields become columns and each instance is a row.

Where you hear it

In Django and SQLAlchemy code, models.py files, and migration discussions.

Examples

  • Add a due_date field to the Payment model.
  • Changing a model means creating a migration.
  • The Payment model has a status field with three possible values.

Common mistake

Using it for any data object. A model is tied to a table; a plain class or dataclass is not.

Don't confuse with

A data model, which is the overall design of the data. A model is one class inside that design.

Say it at work

  • In a meeting or chatWhich model owns this field?
  • In an email or ticketKeep the model thin; put rules in services.