I am working in Django and I have the following class
class Usuario(AbstractBaseUser):
username =models.CharField(verbose_name='Nombre de usuario', max_length=45, unique=True)
date_join =models.DateTimeField(verbose_name='Fecha de alta', auto_now_add=True)
last_login =models.DateTimeField(verbose_name='Última conexión', auto_now=True)
es_docente =models.BooleanField(default=False)
es_estudiante =models.BooleanField(default=False)
es_directivo =models.BooleanField(default=False)
es_preceptor =models.BooleanField(default=False)
es_tutor =models.BooleanField(default=False)
es_superuser =models.BooleanField(default=False)
estado =models.BooleanField(default=True)
now, I would like to add a function to change the boolean states, if it is possible, by using some kind of pattern. I know that the following code is wrong but I didn't find the correct syntax:
def changer(self,var):
es_(%var) = not Usuario.es_(%var)
where I am marking with %var some kind of usage of the input of the function. For example, I would like to input changer(preceptor) and receive as output that the changing of the boolean field es_preceptor.
Thanks in advance!