I am new to django and python. I am creating a job board application and would like to have an option for users to check whether their post is active or inactive. I will be using the BooleanField, but my question is how to I have it read Active or Inactive rather than True or False
In model you can write
from django.utils.translation import ugettext_lazy as _
class MyModel(models.Model):
INACTIVE = 0
ACTIVE = 1
STATUS = (
(INACTIVE, _('Inactive')),
(ACTIVE, _('Active')),
)
active = models.IntegerField(default=0, choices=STATUS)
And instead of IntegerField you can use BooleanField. Then INACTIVE/ACTIVE is True/False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With