'Clean Name'

def clean_username(self):

    data = self.cleaned_data['username']
    query = Q(name=data)
    existing = User.objects.filter(query)
    if existing:
        raise forms.ValidationError((_('User    with    username    %s    already    exists.') % data))
    user_limit = getattr(settings, 'HARDTREE_SUBSCRIPTION_USER_LIMIT', 0)
    if (user_limit > 0):
        user_number = User.objects.filter(disabled=False).count()
        if (user_number >= user_limit):
            raise forms.ValidationError((_("Sorry,    but    your    subscription    does    not    allow    more    than    %d    users.    You're    currently    at    your    limit.") % user_limit))
    return data
