我正在尝试使用 request.session 创建一个“最近”会话密钥并添加用户访问的产品页面以使其在模板中可访问,这是我的观点,你们会推荐什么,我似乎看不到去做这件事
class ProductDetail(DetailView):
model = Producto
template_name = 'productos/product_detail.html'
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(ProductDetail, self).get_context_data(**kwargs)
# Add in a QuerySet of featured products
context['product_list'] = Producto.objects.filter(featured=True).exclude(pk=self.object.pk)
return context
谢谢你的帮助!