From f5836b5437757d0945bbf074b82de648aac02c90 Mon Sep 17 00:00:00 2001 From: Their Name Date: Wed, 10 Aug 2022 01:53:27 +0000 Subject: [PATCH] improve search api --- common/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/views.py b/common/views.py index 2fb56b1c..e527e09a 100644 --- a/common/views.py +++ b/common/views.py @@ -408,6 +408,11 @@ def jump_or_scrape(request, url): # raise ObjectDoesNotExist entity = scraper.data_class.objects.get(source_url=effective_url) # if exists then jump to detail page + if request.path.endswith('.json/'): + return JsonResponse({ + 'num_pages': 1, + 'items': [entity.get_json()] + }) return redirect(entity) except ObjectDoesNotExist: # scrape if not exists