我试图在基于django类的视图中获取动态类名。
这是我的课。
class ProductDetailView(TemplateView): template_name = "%_%_details.html" def get_template_names(self,tmp_name,tmp_name2): return [self.template_name % tmp_name,tmp_name2] def get_context_data(self, **kwargs): context = super(ProductDetailView, self).get_context_data(**kwargs) platform = self.request.GET.get('platform') if platform == "AMAZON": asin = self.request.GET.get('asin') if asin: #products = amazon.search(Keywords=q, SearchIndex='All') products= amazon.lookup(ItemId=asin) template_name = self.get_template_names('amazon','product') context['products'] = products
我想访问模板amazon_product_details.html。
unsupported format character '_' (0x5f) at index 1
访问上述视图时出现错误。
我也尝试用urlib引用,但这也不起作用。
请不要让我知道我在这里做错什么。