My original though was to simply put the email address into both username and email fields when creating accounts, this doesn't work as Django limits the username field to 30 characters which may not be enough for email addresses.
My second thought was to md5 the email address, put the hash into username, and that would make it always unique (and technically, identical to the email field as well). md5 is 32 characters, again I only have 30 characters to work with.
My third thought was to chop the last two characters off the end of the md5 hash, making it 30 and then using it as I had planned to use it with the full hash. But I don't know what the chances are of ending up with two hashes that are identical up to the 30th character and only differing at 31 and 32, which I've chopped off.
Is there a better way to relate the contents of the username field to the email address, in a way that will make it always unique?