I am trying to create a custom form field and validate off it. This is version 1.0 of Django.
Here is my form object
class UsernameField(forms.CharField)
That didn't work in 1.0... here is how I solved it
class UsernameField(forms.CharField):
def clean(self, request, initial=None):
field = super(UsernameField, self).clean(request)
from django.contrib.auth.models import User
user = User(username=request)
if user is not None:
raise forms.ValidationError("That username is already taken")