Tsallaka zuwa abun ciki
Justice Tech School

Field Types

Common fields: CharField, TextField, IntegerField, FloatField, BooleanField, DateField, DateTimeField, EmailField, URLField, ImageField and DecimalField. Options include null, blank, default and unique.

Example
class Product(models.Model):
    name = models.CharField(max_length=100, unique=True)
    price = models.DecimalField(max_digits=8, decimal_places=2)
    in_stock = models.BooleanField(default=True)
    note = models.TextField(blank=True)
    added = models.DateField(null=True, blank=True)

Exercise

Make a value optional in forms.

note = models.TextField(=True)

Quiz Test

What is the difference between null and blank?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.