From 8154ae3685016532164a6778aca69f5d4c647ef7 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 4 Jan 2017 09:51:40 -0500 Subject: [PATCH] Closes #771: Don't automatically redirect user when only one object is returned in a list --- netbox/utilities/views.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index a263ed3ff..3422b2d9d 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -48,8 +48,6 @@ class ObjectListView(View): table: The django-tables2 Table used to render the objects list edit_permissions: Editing controls are displayed only if the user has these permissions template_name: The name of the template - redirect_on_single_result: If True and the queryset returns only a single object, the user is automatically - redirected to that object """ queryset = None filter = None @@ -57,7 +55,6 @@ class ObjectListView(View): table = None edit_permissions = [] template_name = None - redirect_on_single_result = True def get(self, request): @@ -95,13 +92,6 @@ class ObjectListView(View): .format(self.queryset.model._meta.verbose_name_plural) return response - # Attempt to redirect automatically if the search query returns a single result - if self.redirect_on_single_result and self.queryset.count() == 1 and request.GET: - try: - return HttpResponseRedirect(self.queryset[0].get_absolute_url()) - except AttributeError: - pass - # Provide a hook to tweak the queryset based on the request immediately prior to rendering the object list self.queryset = self.alter_queryset(request)