Cannot include "recently viewed products" block on non-product page

The recently_viewed_products template tag in templatetags/history_tags.py does not work if there is no "product" object in the context. This is because it tries to access the id attribute of the product which is None if included on a non-product page .