Dear Django Users,

I want to restrict usernames to be lowercase alphanumeric characters
like this:

def clean_username(username):
    return re.sub(r'\W', '', username).lower()

Now, I'm not sure where is best to do this. I thought it might be
clever to do this using middleware like this:

def process_view(self, request, view_func, view_args, view_kwargs):
    if 'username' in request.POST:
        request.POST['username'] =
clean_username(request.POST['username'])

But, then I saw this note:

https://docs.djangoproject.com/en/dev/topics/http/middleware/#process-view

I've also seen the case insensitive authentication backend approach
here:

http://groups.google.com/group/django-users/browse_thread/thread/2967916ed3c77726/8f1fe50224b4e6ad

But, it seems like I would still be able to create two users one with
username 'admin' and another with username 'Admin'. So, I'll open this
up to the Django pros, any suggestions on how to enforce that all my
users have lowercase alphanumeric usernames?

Thanks,

Andrew

-- 
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.

Reply via email to