I am trying to place a restriction on the minimum number of characters that a subject can use in a form field using Otree
. I want that if the subjects put a name that is less than 4 characters long, the application shows them an error that says they must write a longer word.
I am using len
but I am getting the following error:
'NoneType' has no len()
Can someone help me figure out what is wrong in the code and help me fix it?
This is my pages.py code.
class Consentimiento(Page):
form_model = 'player'
form_fields = ['consentimiento', 'consentimienton',]
def consentimiento_error_message(self, value):
print('El nombre es', value)
if len(self.player.consentimiento)) < Constants.number:
return 'Por favor en el campo de nombre debe poner mínimo 4 letras'
This is my models.py
code
consentimienton = models.StringField( max_length=50 )