diff --git a/python/nav/web/ipam/prefix_tree.py b/python/nav/web/ipam/prefix_tree.py index b3d5e4c1d3..014ba843de 100644 --- a/python/nav/web/ipam/prefix_tree.py +++ b/python/nav/web/ipam/prefix_tree.py @@ -467,10 +467,10 @@ def make_tree(prefixes, family=None, root_ip=None, show_all=None, sort_by="ip"): init = [] if root_ip is not None and root_ip: - scope = Prefix.objects.get(net_address=root_ip) - if scope is not None: + try: + scope = Prefix.objects.get(net_address=root_ip) node = PrefixNode(scope) - else: + except Prefix.DoesNotExist: node = FauxNode(root_ip, "scope", "scope") init.append(node)