unique mark boolean django model field
from django.db import models
class MyModel(models.Model):
unique_mark = models.BooleanField(default=False)
Explanation for each step:
from django.db import models
: This line imports themodels
module from Django, which contains classes and functions for defining database models.class MyModel(models.Model):
: This line defines a Django model namedMyModel
by creating a subclass ofmodels.Model
. This class will represent a database table.unique_mark = models.BooleanField(default=False)
: This line creates a field namedunique_mark
in theMyModel
class. It is defined as a BooleanField, which stores boolean (True/False) values in the database. Thedefault=False
parameter specifies that if no value is provided for this field when creating an instance ofMyModel
, its default value will beFalse
.