Reason for not allowing spaces in usernames?

1,311 views
Skip to first unread message

Wiiboy

unread,
Jun 11, 2009, 11:26:23 PM6/11/09
to Django users
Why does Django not allow spaces in user's usernames? On my site, a
user's username is the first and last name combined (the equivalent of
user.get_full_name()).

Joshua Partogi

unread,
Jun 12, 2009, 2:40:51 AM6/12/09
to django...@googlegroups.com
I guess it's just for simplicity and validation purposes. It would be really difficult to detect users with whitespaces I guess.

--
Join Scrum8.com.

http://scrum8.com/member/jpartogi/
http://scrum8.com/blog/jpartogi/
http://twitter.com/scrum8

Kenneth Gonsalves

unread,
Jun 12, 2009, 2:49:33 AM6/12/09
to django...@googlegroups.com
On Friday 12 June 2009 12:10:51 Joshua Partogi wrote:
> On Jun 12, 1:26 pm, Wiiboy <jordon...@gmail.com> wrote:
> > Why does Django not allow spaces in user's usernames?  On my site, a
> > user's username is the first and last name combined (the equivalent of
> > user.get_full_name()).
>
> I guess it's just for simplicity and validation purposes. It would be
> really difficult to detect users with whitespaces I guess.

or a unix legacy - generally unix usernames do not allow spaces.
--
regards
kg
http://lawgon.livejournal.com

Wiiboy

unread,
Jun 12, 2009, 9:42:06 AM6/12/09
to Django users
Do you think I would have problems if I disabled the checking for
spaces?

When I register users, I have it done automatically (user fills out a
form), and Django doesn't have a problem with a space there. It's
just in the Admin interface.

Marco Louro

unread,
Jun 12, 2009, 9:55:47 AM6/12/09
to Django users
As long as you trim start and trailing spaces, there shouldn't be any
problem, but personally I wouldn't use spaces in usernames at all.

Wiiboy

unread,
Jun 12, 2009, 10:08:12 AM6/12/09
to Django users


On Jun 12, 6:55 am, Marco Louro <mlo...@gmail.com> wrote:
> As long as you trim start and trailing spaces, there shouldn't be any
> problem, but personally I wouldn't use spaces in usernames at all.

Why not?

Tomas Neme

unread,
Nov 17, 2012, 1:18:59 PM11/17/12
to django...@googlegroups.com
> I'm puzzled with this too. Did anyone manage to find a solution to resolving
> spaces in usernames.
>
> Generally a user, these days logs in with their email - that's predominately
> how I've setup all my django projects. People don't remember usernames. It

Well, I can't really agree, but whatever, it shouldn't be hard to do..
just override the forms... at the worse of cases, the User model...

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

Cal Leeming [Simplicity Media Ltd]

unread,
Nov 19, 2012, 12:05:46 AM11/19/12
to django...@googlegroups.com
(imo) Allowing spaces in username just isn't a very sane approach.

Rather than telling the user to choose a username, why not make them login with their email address instead? Users are less likely to forget their email address, and if anything, it would be less error prone than a username would, especially one with spaces.

By all means, you can allow users to have spaces in their alias / nickname field, but allowing them to login with it might not be the best approach.

Hope this helps!

Cal

On Sat, Nov 17, 2012 at 8:14 AM, Paul von Hoesslin <paulvon...@gmail.com> wrote:
I'm puzzled with this too. Did anyone manage to find a solution to resolving spaces in usernames.

Generally a user, these days logs in with their email - that's predominately how I've setup all my django projects. People don't remember usernames. It is legacy, facebook connects with emails, so does gmail and the rest of the world. Username really has fallen back to a NickName / Alternative / Alias kind of field. You'd use it if you knew that in your application people wouldn't want their real, full names to be displayed.

--
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/-/UGdOmEepavIJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Elena Williams

unread,
Nov 19, 2012, 12:12:47 AM11/19/12
to django...@googlegroups.com
Apparently some weirdness can be caused by having email addresses as usernames in django, though I'm not sure specifically what this is.

Does anyone know these cases?

---
Elena :)
@elequ

Russell Keith-Magee

unread,
Nov 19, 2012, 12:32:31 AM11/19/12
to django...@googlegroups.com

If you need to do login via email address, it is possible right now -- it's just a little convoluted. You need to play around with custom authentication backends, and rewrite a bunch of forms.

In Django 1.5, we're addressing this by making the User model customisable. That means you can specify that the "username" is an EmailField, of whatever length you like, or you can specify the username is an "alias", which allows spaces -- whatever your use case requires. 

For more details, see the docs for the new feature [1]; 1.5 final should be released towards the end of this year.


Yours
Russ Magee %-)


On Sat, Nov 17, 2012 at 4:14 PM, Paul von Hoesslin <paulvon...@gmail.com> wrote:
I'm puzzled with this too. Did anyone manage to find a solution to resolving spaces in usernames.

Generally a user, these days logs in with their email - that's predominately how I've setup all my django projects. People don't remember usernames. It is legacy, facebook connects with emails, so does gmail and the rest of the world. Username really has fallen back to a NickName / Alternative / Alias kind of field. You'd use it if you knew that in your application people wouldn't want their real, full names to be displayed.


On Friday, June 12, 2009 4:08:12 PM UTC+2, Wiiboy wrote:

--

Russell Keith-Magee

unread,
Nov 19, 2012, 12:33:23 AM11/19/12
to django...@googlegroups.com

One obvious problem case -- email addresses longer than 30 characters. The current username field has a 30 character max, which is easy to exceed if you try and put email addresses into the username field.

Django 1.5 addresses this by allowing your user model to be customisable, so you can make the username constraints whatever you want.

Yours,
Russ Magee %-)
Reply all
Reply to author
Forward
0 new messages