Jeremy Stretch 5 лет назад
Родитель
Сommit
0a6ebdee48

+ 3 - 2
netbox/extras/querysets.py

@@ -1,7 +1,8 @@
+from django.contrib.postgres.aggregates import JSONBAgg
 from django.db.models import OuterRef, Subquery, Q
 
 from extras.models.tags import TaggedItem
-from utilities.query_functions import EmptyGroupByJSONBAgg, OrderableJSONBAgg
+from utilities.query_functions import EmptyGroupByJSONBAgg
 from utilities.querysets import RestrictedQuerySet
 
 
@@ -47,7 +48,7 @@ class ConfigContextQuerySet(RestrictedQuerySet):
 
         if aggregate_data:
             return queryset.aggregate(
-                config_context_data=OrderableJSONBAgg('data', ordering=['weight', 'name'])
+                config_context_data=JSONBAgg('data', ordering=['weight', 'name'])
             )['config_context_data']
 
         return queryset

+ 1 - 0
netbox/ipam/tests/test_views.py

@@ -210,6 +210,7 @@ class PrefixTestCase(ViewTestCases.PrimaryObjectViewTestCase):
             Role(name='Role 1', slug='role-1'),
             Role(name='Role 2', slug='role-2'),
         )
+        Role.objects.bulk_create(roles)
 
         Prefix.objects.bulk_create([
             Prefix(prefix=IPNetwork('10.1.0.0/16'), vrf=vrfs[0], site=sites[0], role=roles[0]),

+ 2 - 0
netbox/netbox/settings.py

@@ -375,6 +375,8 @@ LOGIN_URL = '/{}login/'.format(BASE_PATH)
 
 CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
 
+DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
+
 # Exclude potentially sensitive models from wildcard view exemption. These may still be exempted
 # by specifying the model individually in the EXEMPT_VIEW_PERMISSIONS configuration parameter.
 EXEMPT_EXCLUDE_MODELS = (

+ 1 - 11
netbox/utilities/query_functions.py

@@ -1,5 +1,4 @@
 from django.contrib.postgres.aggregates import JSONBAgg
-from django.contrib.postgres.aggregates.mixins import OrderableAggMixin
 from django.db.models import F, Func
 
 
@@ -11,19 +10,10 @@ class CollateAsChar(Func):
     template = '(%(expressions)s) COLLATE "%(function)s"'
 
 
-class OrderableJSONBAgg(OrderableAggMixin, JSONBAgg):
-    """
-    TODO in Django 3.2 ordering is supported natively on JSONBAgg so this is no longer needed.
-    """
-    template = '%(function)s(%(distinct)s%(expressions)s %(ordering)s)'
-
-
-class EmptyGroupByJSONBAgg(OrderableJSONBAgg):
+class EmptyGroupByJSONBAgg(JSONBAgg):
     """
     JSONBAgg is a builtin aggregation function which means it includes the use of a GROUP BY clause.
     When used as an annotation for collecting config context data objects, the GROUP BY is
     incorrect. This subclass overrides the Django ORM aggregation control to remove the GROUP BY.
-
-    TODO in Django 3.2 ordering is supported natively on JSONBAgg so we only need to inherit from JSONBAgg.
     """
     contains_aggregate = False

+ 1 - 1
requirements.txt

@@ -1,4 +1,4 @@
-Django==3.1.3
+Django==3.2b1
 django-cacheops==5.1
 django-cors-headers==3.5.0
 django-debug-toolbar==3.1.1