我是django-lfs的新手。
我一直在玩代码,试图建立一个商店来满足我的需求。我遇到了一个我无法解决的问题。
我需要从产品视图(catalog/ product /inline)访问我访问此页面的类别。如果y显示面包屑,我可以看到它。例如:主页>类别1>产品1,但是我不能访问“类别”对象,所以我可以使用它的数据。
有没有人能帮我。
提前感谢
发布于 2011-10-19 16:16:57
我已经成功地添加了一个模板标签...
并不完全是我wanted..but工作的很好。
@register.inclusion_tag('tagging/lateral_menu.html', takes_context=True)
def lateral_menu(context):
object = context.get("category") or context.get("product")
if object.__class__.__name__.lower() == "product":
request = context.get("request")
category=lfs.catalog.utils.get_current_product_category(request, object)
else:
category = object
top_category=category
while top_category.parent is not None:
top_category = category.parent
categories =top_category.get_all_children()
return {"category" :category, "top_category" : top_category, "categories" : categories }然后在模板中,我可以获得我需要的所有数据。
https://stackoverflow.com/questions/7804383
复制相似问题