7. Model About

7.1. Rationale

  • What are model fields?

  • Model field arguments

  • Fat model architecture

  • Single File vs. Models per file

7.2. Attributes

  • verbose_name

  • max_length

  • choices

  • validators

  • help_text

  • null

  • blank

  • default

  • db_index

  • db_column

  • default

  • limit_choices_to

  • editable

  • primary_key

  • help_text

  • error_message

  • unique

7.3. Abstract Models

class Meta:
    abstract = True

7.4. Database schema migration

Makemigrations:

$ python manage.py makemigrations
Migrations for 'contact':
  addressbook/contact/migrations/0001_initial.py
    - Create model Contact

Migrate:

$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, contact, sessions
Running migrations:
  Applying contact.0001_initial... OK