【问题标题】:Django oscar custom template file structureDjango oscar 自定义模板文件结构
【发布时间】:2013-11-28 12:12:30
【问题描述】:

我正在尝试为 django oscar 编写我的自定义模板。我的模板结构与原始 oscar 的模板完全不同。但目前它使用了许多默认的 oscar 视图。

问题是模板路径在 oscar 的默认视图中是硬编码的。即

template_name = 'catalogue/browse.html'

我需要类似的东西:

template_name = 'anotherdir/index.html'

覆盖此模板路径并保留默认 oscar 视图逻辑的最佳/最简单方法是什么?

【问题讨论】:

    标签: django-templates django-oscar


    【解决方案1】:

    这样做的方法是扩展您想要更改模板的视图,然后只需覆盖“template_name”变量。

    例如:

    from oscar.apps.catalogue.views import ProductCategoryView as OscarProductCategoryView
    
    class ProductCategoryView(OscarProductCategoryView):
        template_name = 'anotherdir/index.html'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2021-09-03
      • 1970-01-01
      • 2018-01-14
      • 2016-12-15
      • 2012-05-26
      相关资源
      最近更新 更多