mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Closes #771: Don't automatically redirect user when only one object is returned in a list
This commit is contained in:
parent
7f297b4733
commit
8154ae3685
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user