Choosing Field Types
CharField, TextField, IntegerField, and friends.
Pick the Right Field
Each column needs a field type that matches its data. Choosing well keeps your database tidy and your validation automatic.
CharField for Short Text
Use CharField for short strings like names or titles. It always needs a max_length to size the column.
title = models.CharField(max_length=200)All lessons in this course
- Defining a Model Class
- Choosing Field Types
- Field Options: null, blank, default
- str and the Meta Class