Browse Source

Fixes #943: Child prefixes missing on Python 3

Jeremy Stretch 8 years ago
parent
commit
d89314a559
2 changed files with 2 additions and 8 deletions
  1. 1 1
      netbox/ipam/models.py
  2. 1 7
      netbox/ipam/views.py

+ 1 - 1
netbox/ipam/models.py

@@ -267,7 +267,7 @@ class PrefixQuerySet(NullsFirstQuerySet):
             p.depth = len(stack) - 1
             p.depth = len(stack) - 1
         if limit is None:
         if limit is None:
             return queryset
             return queryset
-        return filter(lambda p: p.depth <= limit, queryset)
+        return list(filter(lambda p: p.depth <= limit, queryset))
 
 
 
 
 @python_2_unicode_compatible
 @python_2_unicode_compatible

+ 1 - 7
netbox/ipam/views.py

@@ -420,13 +420,7 @@ def prefix(request, pk):
     duplicate_prefix_table.exclude = ('vrf',)
     duplicate_prefix_table.exclude = ('vrf',)
 
 
     # Child prefixes table
     # Child prefixes table
-    if prefix.vrf:
-        # If the prefix is in a VRF, show child prefixes only within that VRF.
-        child_prefixes = Prefix.objects.filter(vrf=prefix.vrf)
-    else:
-        # If the prefix is in the global table, show child prefixes from all VRFs.
-        child_prefixes = Prefix.objects.all()
-    child_prefixes = child_prefixes.filter(prefix__net_contained=str(prefix.prefix))\
+    child_prefixes = Prefix.objects.filter(vrf=prefix.vrf, prefix__net_contained=str(prefix.prefix))\
         .select_related('site', 'role').annotate_depth(limit=0)
         .select_related('site', 'role').annotate_depth(limit=0)
     if child_prefixes:
     if child_prefixes:
         child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes)
         child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes)