Skip to content

Commit

Permalink
fix:add redirect for missing query in search view
Browse files Browse the repository at this point in the history
If 'query' is not in the request GET parameters, the view now redirects to the homepage with an empty query string. This ensures users don't face errors when accessing the search page without a query parameter.
  • Loading branch information
hareshkainthdbt committed Oct 14, 2024
1 parent 61a7b8c commit 58db5e1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion orp/orp_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect, render
from django.views.decorators.http import require_http_methods

from core.forms import RegulationSearchForm
Expand Down Expand Up @@ -63,6 +63,9 @@ def search(request: HttpRequest) -> HttpResponse:
during the Data API search, the service problem page is displayed.
"""

if "query" not in request.GET:
return redirect("/?query=")

context = {
"service_name": settings.SERVICE_NAME_SEARCH,
}
Expand Down

0 comments on commit 58db5e1

Please sign in to comment.