From e09ab28bec027c0d6a5aa3325e916110e2ed5615 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 18 Dec 2016 09:52:20 +0000 Subject: [PATCH] =?UTF-8?q?No=20crash=20=C3=A0=20la=20migration=20initiale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/users/models.py b/users/models.py index 1cd19787..01f7a34c 100644 --- a/users/models.py +++ b/users/models.py @@ -44,7 +44,10 @@ def linux_user_validator(login): def get_fresh_user_uid(): uids = list(range(int(min(UID_RANGES['users'])),int(max(UID_RANGES['users'])))) - used_uids = [ user.uid_number for user in User.objects.all()] + try: + used_uids = [ user.uid_number for user in User.objects.all()] + except: + used_uids = [] free_uids = [ id for id in uids if id not in used_uids] return min(free_uids)