it somehow keeps returning True on everything
-- accepted = string.letters + string.digits
max_numbers = 4
def test(word):
numbers = 0
for c in word:
if c.isdigit():
numbers += 1
if not c in accepted or numbers > max_numbers:
return False
return True
# profielnaam
class ProfielenForm(forms.ModelForm):
def clean_profielnaam(self):
logger.debug('>>>>>>>>>>>FORMS<<<<<<<<< %s', accepted)
data = self.cleaned_data['profielnaam']
testdata = test(data)
logger.debug('>>>>>>>>>>>FORMS<<<<<<<<<< >>>>>DATA<<<<< %s', testdata)
if testdata is "False":
raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")
return data
class Meta:
model = Profielen
fields = ('profielnaam',)
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment