Skip to content

Commit cc62f92

Browse files
committed
new: split SearchView.create_response into get_context
This makes it easy to override the default `create_response` behaviour if you don't want a standard HTML response. Thanks @seocam for the patch Closes django-haystack#1338
1 parent e5b969a commit cc62f92

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

haystack/views.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ def extra_context(self):
124124
"""
125125
return {}
126126

127-
def create_response(self):
128-
"""
129-
Generates the actual HttpResponse to send back to the user.
130-
"""
127+
def get_context(self):
131128
(paginator, page) = self.build_page()
132129

133130
context = {
@@ -142,6 +139,16 @@ def create_response(self):
142139
context['suggestion'] = self.form.get_suggestion()
143140

144141
context.update(self.extra_context())
142+
143+
return context
144+
145+
def create_response(self):
146+
"""
147+
Generates the actual HttpResponse to send back to the user.
148+
"""
149+
150+
context = self.get_context()
151+
145152
return render(self.request, self.template, context)
146153

147154

0 commit comments

Comments
 (0)