Choosing Field Types
CharField, TextField, IntegerField, and friends.
Choosing Field Types is a free Django Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Django Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
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)TextField for Long Text
Reach for TextField when text can be long, like an article body. It needs no max_length at all.
body = models.TextField()IntegerField for Whole Numbers
Store whole numbers in an IntegerField, perfect for counts, page totals, or quantities in stock.
pages = models.IntegerField()BooleanField for True or False
A BooleanField holds a simple true or false flag, ideal for things like published or is_active. ✅
published = models.BooleanField(default=False)DateField and DateTimeField
Track time with DateField for calendar dates and DateTimeField when you also need the exact time of day.
created = models.DateTimeField(auto_now_add=True)DecimalField for Money
For prices, use DecimalField with max_digits and decimal_places. It avoids the rounding errors that floats cause.
price = models.DecimalField(max_digits=6, decimal_places=2)EmailField Adds Validation
An EmailField is a CharField that also checks the value looks like a real email address for you.
email = models.EmailField()SlugField for URLs
A SlugField stores short, URL-friendly labels like my-first-post, made of letters, numbers, and hyphens.
slug = models.SlugField(unique=True)Fields Bring Free Validation
The big win: each field type validates and renders the right form widget automatically, so you write far less checking code.
Match Type to Meaning
Always pick the field that matches what the data means, not just what fits. A price is a Decimal, not text.
Quick Check
Which field would you choose for a product price?
Recap: Field Types
You met the core field types: CharField and TextField for text, IntegerField and DecimalField for numbers, plus dates and booleans. Choose by meaning! 👍
Frequently asked questions
Is the “Choosing Field Types” lesson free?
Yes — the full text of “Choosing Field Types” is free to read here on the web, and the Django Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Django Academy course, upgrade to CoddyKit PRO.
What will I learn in “Choosing Field Types”?
CharField, TextField, IntegerField, and friends. You practise Django Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Django Academy?
No prior experience is required. Django Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Choosing Field Types” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Django Academy lesson?
Yes. Every Django Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Defining a Model Class
- Choosing Field Types
- Field Options: null, blank, default
- str and the Meta Class