Don't crash when migrating users with blank name

Some users are registered with just a username and no actual name. The
old way only dealt with users with just first or last name - not the
ones completely without name.
This commit is contained in:
Magnus Hagander
2011-12-08 19:43:47 +01:00
parent 38bad00e63
commit 580c85b059

View File

@ -34,6 +34,7 @@ class AuthBackend(ModelBackend):
# create a user in the django system, and migrate all settings
# we can think of.
namepieces = rows[0][2].split(None, 2)
if len(namepieces) == 0: namepieces = ['', '']
if len(namepieces) == 1: namepieces.append('')
user = User(username=username.lower(), email=rows[0][3], first_name=namepieces[0], last_name=namepieces[1])
user.set_password(password)