You aren't the first person to suggest this, and it's something I'm
interested in looking at in the v1.2 timeframe. This is a very common
question, and one for which Django needs to have a clear and well
documented solution. Ticket #3011 has one solution; I'm not completely
convinced that the patch on that ticket is the whole solution, though.
Yours,
Russ Magee %-)
You write a custom authentication function that compares the username
and password supplied by the user in the login form against the email
address and password fields in the User model -- fetch the User
instance(s) matching the email address and then use the check_password()
method on the User instance to see if it's valid.
It should only a couple of lines of code in the skeleton code described
here:
http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend
Regards,
Malcolm
Nothing stops you from creating a random string to populate the username
field with. It has to contain a unique identifier and it's often useful
if that is actually identifiable -- perhaps created from an amalgam of
the user's first and last names or something -- but it could be entirely
random, providing it is unique.
So when you are registering the user, just create a username string
however you like. The user themselves doesn't have to know or care what
it is. The thing is, their username won't change, their email address
might (one of the many small problems with email addresses as unique and
unchanging identifiers).
Regards,
Malcolm