Bläddra i källkod

Fixes #9151: Child prefix counts not annotated on aggregates list under RIR view

jeremystretch 3 år sedan
förälder
incheckning
671e1aed9f
2 ändrade filer med 3 tillägg och 2 borttagningar
  1. 1 0
      docs/release-notes/version-3.2.md
  2. 2 2
      netbox/ipam/views.py

+ 1 - 0
docs/release-notes/version-3.2.md

@@ -5,6 +5,7 @@
 ### Bug Fixes
 
 * [#9133](https://github.com/netbox-community/netbox/issues/9133) - Upgrade script should require Python 3.8 or later
+* [#9151](https://github.com/netbox-community/netbox/issues/9151) - Child prefix counts not annotated on aggregates list under RIR view
 * [#9156](https://github.com/netbox-community/netbox/issues/9156) - Fix loading UserConfig data from fixtures
 
 ---

+ 2 - 2
netbox/ipam/views.py

@@ -158,8 +158,8 @@ class RIRView(generic.ObjectView):
     queryset = RIR.objects.all()
 
     def get_extra_context(self, request, instance):
-        aggregates = Aggregate.objects.restrict(request.user, 'view').filter(
-            rir=instance
+        aggregates = Aggregate.objects.restrict(request.user, 'view').filter(rir=instance).annotate(
+            child_count=RawSQL('SELECT COUNT(*) FROM ipam_prefix WHERE ipam_prefix.prefix <<= ipam_aggregate.prefix', ())
         )
         aggregates_table = tables.AggregateTable(aggregates, exclude=('rir', 'utilization'))
         aggregates_table.configure(request)