Last modified: Jan 10, 2023 By Alexander Williams

Django BooleanField (Examples)

Example 1


class Message(models.Model):
    message = models.TextField()
    related = models.BooleanField(default=False)
    request = models.BooleanField(default=False)
    offer = models.BooleanField(default=False)
    aid_related = models.BooleanField(default=False)
    medical_help = models.BooleanField(default=False)
    medical_products = models.BooleanField(default=False)
    search_and_rescue = models.BooleanField(default=False)
    security = models.BooleanField(default=False)
    military = models.BooleanField(default=False)
    child_alone = models.BooleanField(default=False)
    water = models.BooleanField(default=False)
    food = models.BooleanField(default=False)
    shelter = models.BooleanField(default=False)
    clothing = models.BooleanField(default=False)
    money = models.BooleanField(default=False)
    missing_people = models.BooleanField(default=False)
    refugees = models.BooleanField(default=False)
    death = models.BooleanField(default=False)
    other_aid = models.BooleanField(default=False)
    infrastructure_related = models.BooleanField(default=False)
    transport = models.BooleanField(default=False)
    buildings = models.BooleanField(default=False)
    electricity = models.BooleanField(default=False)
    tools = models.BooleanField(default=False)
    hospitals = models.BooleanField(default=False)
    shops = models.BooleanField(default=False)
    aid_centers = models.BooleanField(default=False)
    other_infrastructure = models.BooleanField(default=False)
    weather_related = models.BooleanField(default=False)
    floods = models.BooleanField(default=False)
    storm = models.BooleanField(default=False)
    fire = models.BooleanField(default=False)
    earthquake = models.BooleanField(default=False)
    cold = models.BooleanField(default=False)
    other_weather = models.BooleanField(default=False)
    direct_report = models.BooleanField(default=False)

    def __str__(self):
        """Represent the object as a string"""

        return self.message

Example 2


class Post(models.Model):
    title=models.CharField(max_length=128)
    content=models.TextField()

    #########
    # General
    Nausea = models.BooleanField()
    Body_Aches = models.BooleanField()
    Chills = models.BooleanField()
    Fatigue = models.BooleanField()

    # Head
    Runny_Nose = models.BooleanField()
    Sore_Throat = models.BooleanField()
    Cough = models.BooleanField()
    Nasal_Congestion = models.BooleanField()
    Headache = models.BooleanField()
    Sneezing = models.BooleanField()
    Fever = models.BooleanField()

    Eye_Redness = models.BooleanField()
    Eye_Itchiness = models.BooleanField()
    Eye_Gritty = models.BooleanField()
    Eye_Discharge = models.BooleanField()
    Eye_Tearing = models.BooleanField()
    Itchy_Nose_Mouth_Throat = models.BooleanField()
    Eyes_Swollen = models.BooleanField()
    Postnasal_Drip = models.BooleanField()
    Mucus_White = models.BooleanField()
    Mucus_GreenYellow = models.BooleanField()


    # Chest
    Heartburn = models.BooleanField()
    Vomiting = models.BooleanField()

    # Abdomen
  #  Indigestion = models.BooleanField()
    Diarrhoea = models.BooleanField()
    Abdominal_Cramps = models.BooleanField()

    # Limbs
    Sore_Joint = models.BooleanField()
    Sore_Muscles = models.BooleanField()


    def __unicode__(self):
        return self.title

    def _str_(self):
        return self.title

Example 3


class Tabla_resultados_transporte(models.Model):
    empresa = models.ForeignKey(User, on_delete=models.CASCADE)
    answer1 = models.BooleanField(default=False)
    answer2 = models.BooleanField(default=False)
    answer3 = models.BooleanField(default=False)
    answer4 = models.BooleanField(default=False)
    answer5 = models.BooleanField(default=False)
    answer6 = models.BooleanField(default=False)
    answer7 = models.BooleanField(default=False)
    answer8 = models.BooleanField(default=False)
    answer9 = models.BooleanField(default=False)


Example 4


class Corporate_Login(models.Model):
    name = models.CharField(default=True,max_length=200)
    email = models.CharField(default=True,max_length=200)
    password = models.CharField(max_length=100)
    contact_no = models.CharField(default=True,max_length=100)
    corporate_id = models.CharField(default=True,max_length=10)
    last_login = models.DateTimeField(default=True,max_length=100)
    is_radio = models.BooleanField()
    is_local = models.BooleanField()
    is_outstation = models.BooleanField()
    is_bus = models.BooleanField()
    is_train = models.BooleanField()
    is_hotel = models.BooleanField()
    is_meal = models.BooleanField()
    is_flight = models.BooleanField()
    is_water_bottles = models.BooleanField()
    is_reverse_logistics = models.BooleanField()
    is_send_email = models.BooleanField()
    is_send_sms = models.BooleanField()
    has_billing_access = models.BooleanField()
    is_deleted = models.BooleanField()
    class Meta:
        db_table = "corporate_logins"

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)

    def __repr__(self):
        return '' % (self.name)

Example 5


class Corporate_Agent(models.Model):
    user_name = models.CharField(max_length=200)
    emp_id = models.CharField(max_length=200)
    email = models.CharField(max_length=200)
    password = models.CharField(max_length=100)
    contact_no = models.CharField(max_length=100)
    status = models.CharField(max_length=10)
    is_relationship_manager = models.CharField(max_length=100)
    is_operation_manager = models.CharField(max_length=100)
    is_deleted = models.BooleanField()

Example 6


class Corporate_Agent(models.Model):
    user_name = models.CharField(max_length=200)
    emp_id = models.CharField(max_length=200)
    email = models.CharField(max_length=200)
    password = models.CharField(max_length=100)
    contact_no = models.CharField(max_length=100)
    status = models.CharField(max_length=10)
    last_login = models.DateTimeField(max_length=100)
    has_radio_booking_access = models.CharField(max_length=100)
    has_local_booking_access = models.CharField(max_length=100)
    has_outstation_booking_access = models.CharField(max_length=100)
    has_bus_booking_access = models.CharField(max_length=100)
    has_train_booking_access = models.CharField(max_length=100)
    has_hotel_booking_access = models.CharField(max_length=100)
    has_flight_booking_access = models.CharField(max_length=100)
    has_meal_booking_access = models.CharField(max_length=100)
    has_water_bottles_booking_access = models.CharField(max_length=100)
    has_reverse_logistics_booking_access = models.CharField(max_length=100)
    has_billing_access = models.CharField(max_length=100)
    has_voucher_payment_access = models.CharField(max_length=100)
    has_voucher_approval_access = models.CharField(max_length=100)
    is_super_admin = models.CharField(max_length=100)
    is_relationship_manager = models.CharField(max_length=100)
    is_operation_manager = models.CharField(max_length=100)
    is_deleted = models.BooleanField()