from django import forms
""" slower clean() method using regex
def clean(self, value):
import re
if not re.search('[a-zA-Z]+', value) or not re.search('[0-9]+', value):
raise forms.ValidationError(u'Your password must include at least \
one letter and at least one number.')
"""
# Password Field (Extends CharField) (Optimized Version)
import string
class PasswordField(forms.CharField):
# Setup the Field
def __init__(self, *args, **kwargs):
super(PasswordField, self).__init__(min_length = 7, required = True,
label = u'Password',
widget = forms.PasswordInput(render_value = False),
*args, **kwargs)
# Validate - 1+ Numbers, 1+ Letters
def clean (self, value):
# Setup Our Lists of Characters and Numbers
characters = list(string.letters)
numbers = [str(i) for i in range(10)]
# Assume False until Proven Otherwise
numCheck = False
charCheck = False
# Loop until we Match
for char in value:
if not charCheck:
if char in characters:
charCheck = True
if not numCheck:
if char in numbers:
numCheck = True
if numCheck and charCheck:
break
if not numCheck or not charCheck:
raise forms.ValidationError(u'Your password must include at least \
one letter and at least one number.')
return super(PasswordField, self).clean(value)
Comments
We forgot a very important part of this. It needs to be added on to the end of the clean function(s):
[HTML_REMOVED]return super(PasswordField, self).clean(value)[HTML_REMOVED]
#
Whoops, I used the wrong syntax for the code. Anyways, here it is:
return super(PasswordField, self).clean(value)#
*╭╮ ╭╮ ╭╮ ││ ││ │└╮ ╭┴┴─┴Ⅲ╮~└─╯ │ ﹋ ﹋ │ ╭─────────╮ │ ∩ ∩ │ ╭╮ http://www.fullmalls.com │ ▽ │O╰╯╰─────────╯
╰─m∞m─╯
The website wholesale for many kinds of fashion shoes, like the nike,jordan,prada,, also including the jeans,shirts,bags,hat and the decorations. All the products are free shipping, and the the price is competitive, and also can accept the paypal payment.,after the payment, can ship within short time.
free shipping
competitive price
any size available
accept the paypal
jordan shoes $32
nike shox $32
Christan Audigier bikini $23
Ed Hardy Bikini $23
Smful short_t-shirt_woman $15
ed hardy short_tank_woman $16
Sandal $32
christian louboutin $80
Sunglass $15
COACH_Necklace $27
handbag $33
AF tank woman $17
puma slipper woman $30
====( http://www.fullmalls.com )=====
#
Nice catch kurtis, I added in the missing line. Thanks.
#