DBに2つのカテゴリがリストされています。
選択したカテゴリに応じて、テンプレート(templates> product> category.html)を変更したいと思います。(カテゴリごとに配色やヘッダー画像を変更したいからです)
これどうやってするの?で指定されているテンプレートを変更できますか?
def category_view(request, slug, parent_slugs='', template='product/category.html'):
これはproduct.viewsにありますか?
ありがとう
これは現在私のcategory_viewであり、http500エラーと無効な構文のpythondjangoエラーを返します。
def category_view(request, slug, parent_slugs='', template='product/category.html'):
"""Display the category, its child categories, and its products.
Parameters:
- slug: slug of category
- parent_slugs: ignored
"""
try:
category = Category.objects.get_by_site(slug=slug)
products = list(category.active_products())
sale = find_best_auto_discount(products)
except Category.DoesNotExist:
return bad_or_missing(request, _('The category you have requested does not exist.'))
child_categories = category.get_all_children()
ctx = {
'category': category,
'child_categories': child_categories,
'sale' : sale,
'products' : products,
}
if slug == 'healing-products'
template = 'product/i.html'
if slug == 'beauty-products'
template ='product/category_beauty.html'
index_prerender.send(Product, request=request, context=ctx, category=category, object_list=products)
return render_to_response(template, context_instance=RequestContext(request, ctx))