diff --git a/localauth/helpers.py b/localauth/helpers.py index 43e5640..797d966 100644 --- a/localauth/helpers.py +++ b/localauth/helpers.py @@ -18,7 +18,12 @@ def profile_to_coords(profile): return name_to_coords("%s, %s, %s, %s" % (profile.street, profile.city, profile.zip, profile.country)) def upload_path(instance, filename): - return f'userfiles/{instance.user.id}/{uuid.uuid4()}/{filename}' + try: + user_id = instance.user.id + except: + user_id = "global" + + return f'userfiles/{user_id}/{uuid.uuid4()}/{filename}' def generate_token(length=6, characters=string.digits): return "".join([SystemRandom().choice(characters) for _ in range(length)])