I was wrong. There wasn't any issue with the unicode. Your fixed worked perfectly. I just had to change my comparison from
password is not password_confirm to password != password_confirm and it's working great now. Thanks a lot! On Thu, Sep 22, 2011 at 12:04 PM, Kurtis Mullins <kurtis.mull...@gmail.com>wrote: > Thanks Daniel! You were right on cue with that. I tried your code and for > some reason the value is being returned as a standard string instead of a > unicode string, as far as I can tell. (Effectively, my password and > passwordConfirm are not matching anymore). Hopefully once I get that worked > out, things will be working great. > > > On Thu, Sep 22, 2011 at 11:56 AM, Daniel Roseman <dan...@roseman.org.uk>wrote: > >> On Thursday, 22 September 2011 15:18:15 UTC+1, Kurtis wrote: >>> >>> Sorry, I guess I should've posted that as well :) >>> >>> 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 List of Characters >>> lower = list(string.lowercase[:26]) >>> upper = list(string.uppercase[:26]) >>> 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 lower or char in upper: >>> 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.') >>> >>> >> You need to ensure that it returns the value if it is valid. Currently, >> your code raises an error if it is invalid, but returns `None` if it is >> valid - you should explicitly return `value`. >> Actually, even better, you should call the superclass `clean` method and >> return the value from that: >> return super(PasswordField, self).clean(value) >> -- >> DR. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/96liwPhxphwJ. >> >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.