Hacker News new | ask | show | jobs
by superxor 4908 days ago
God, I was so fed up with django.contrib.auth.models.User, not being able to ignore Username was probably the most insane part, I always felt email was a better choice than Username. I along with a bunch of people I know are looking forward to swappable User model, far saner than the round-about approaches I was using.
2 comments

Very much agree with this. Websites rarely require users to choose a unique username nowadays (email is enough) and it's been a pain hacking Django to work like that, since many email addresses won't fit in the username field.

In fact I always hate it when application frameworks make arbitrary decisions at the schema level on how long usernames, real names, emails, street addresses, etc. can be. I always use varchar(254) myself. (Unless using a schemaless db like Mongo where this is not even an issue.)

It's not terribly straight forward to do this, depending on which apps you may use. E.g. django-registration or even django.contrib.admin. Username is hard coded in many places. It will get there, but apps have some work to do.
I think you can just override the default clean_username() in RegistrationForm:

https://bitbucket.org/ubernostrum/django-registration/src/27...

Looks like that's the only place that enforces duplicate usernames.