def import_admins(self):
self.message('<STR_LIT>')<EOL>saved_admins = []<EOL>for olduser in OldUser.objects.all():<EOL><INDENT>try:<EOL><INDENT>user = User.objects.get(Q(username=olduser.username) | Q(email=olduser.email))<EOL><DEDENT>except User.DoesNotExist:<EOL><INDENT>user = User()<EOL><DEDENT>except User.MultipleObjectsReturned:<EOL><INDENT>continue<EOL><DEDENT>user.username = olduser.username<EOL>user.password = olduser.password<EOL>user.first_name = olduser.first_name<EOL>user.last_name = olduser.last_name<EOL>user.email = olduser.email<EOL>user.is_active = olduser.is_active<EOL>user.is_staff = olduser.is_staff<EOL>user.is_superuser = olduser.is_superuser<EOL>user.date_joined = olduser.date_joined<EOL>user.full_clean()<EOL>user.save(sync_emailaddress=False)<EOL>saved_admins.append(user)<EOL>if EMAIL_CONFIRMATION and EmailAddress.objects.filter(email=user.email).count() is <NUM_LIT:0>:<EOL><INDENT>try:<EOL><INDENT>email_address = EmailAddress(user=user, email=user.email, verified=True, primary=True)<EOL>email_address.full_clean()<EOL>email_address.save()<EOL><DEDENT>except Exception:<EOL><INDENT>tb = traceback.format_exc()<EOL>self.message('<STR_LIT>' % (user.username, tb))<EOL><DEDENT><DEDENT><DEDENT>self.message('<STR_LIT>' % len(saved_admins))<EOL>self.saved_admins = saved_admins<EOL>
save admins to local DB