+class UserManager(CachedManager):
+ def get(self, *args, **kwargs):
+ if not len(args) and len(kwargs) == 1 and 'username' in kwargs:
+ matching_users = self.filter(username=kwargs['username'])
+
+ if len(matching_users) == 1:
+ return matching_users[0]
+ elif len(matching_users) > 1:
+ for user in matching_users:
+ if user.username == kwargs['username']:
+ return user
+ return matching_users[0]
+ return super(UserManager, self).get(*args, **kwargs)
+