improve search api
This commit is contained in:
parent
6ee577620a
commit
f5836b5437
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue