From 7343ae73397089c6e8d45ec91d8f5df5bd65c754 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 22 Dec 2021 10:45:21 -0500 Subject: [PATCH] Fix invalid key retrieval --- netbox/users/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netbox/users/models.py b/netbox/users/models.py index 0afc7d374..0ce91363b 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -82,9 +82,9 @@ class UserConfig(models.Model): # Iterate down the hierarchy, returning the default value if any invalid key is encountered try: for key in keys: - d = d.get(key) + d = d[key] return d - except (AttributeError, KeyError): + except (TypeError, KeyError): pass # If the key is not found in the user's config, check for an application-wide default @@ -92,9 +92,9 @@ class UserConfig(models.Model): d = config.DEFAULT_USER_PREFERENCES try: for key in keys: - d = d.get(key) + d = d[key] return d - except (AttributeError, KeyError): + except (TypeError, KeyError): pass # Finally, return the specified default value (if any)