开发者

Django, Haystack: show the time took by a search

开发者 https://www.devze.com 2023-01-30 17:13 出处:网络
I have a Django app that uses Haystack. Is it poss开发者_StackOverflow中文版ible to show after a search, in the search result page, how much time the search took ?You can use the time module from pyth

I have a Django app that uses Haystack. Is it poss开发者_StackOverflow中文版ible to show after a search, in the search result page, how much time the search took ?


You can use the time module from python to achieve that:

import time

start = time.time()
# code which performs search
end = time.time()
time_taken = end - start

Push time_taken to your template.

0

精彩评论

暂无评论...
验证码 换一张
取 消