Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c96b4e1

Browse files
janheiniacdha
authored andcommitted
fix: handle HEAD requests like GET in generic_views
HEAD requests caused an exception before. Handle them like GET requests. Fixes #1956
1 parent 2e9969b commit c96b4e1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

haystack/generic_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_form_kwargs(self):
5959
Returns the keyword arguments for instantiating the form.
6060
"""
6161
kwargs = {"initial": self.get_initial()}
62-
if self.request.method == "GET":
62+
if self.request.method in ["HEAD", "GET"]:
6363
kwargs.update({"data": self.request.GET})
6464
kwargs.update(
6565
{"searchqueryset": self.get_queryset(), "load_all": self.load_all}

test_haystack/test_generic_views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,11 @@ def get_request(self, url, method="get", data=None, **kwargs):
7171

7272
request = factory_func(url, data=data or {}, **kwargs)
7373
return request
74+
75+
76+
class GenericSearchViewsHEADTestCase(GenericSearchViewsTestCase):
77+
"""Test case for the generic search views using the HEAD request method."""
78+
79+
def setUp(self):
80+
super().setUp()
81+
self.request.method = "HEAD"

0 commit comments

Comments
 (0)