satchmo 中的自定义产品模板
我正在 satchmo 建立一家商店。我通过使用产品模型的模型继承创建了一个自定义产品MyProduct(如http://thisismedium.com/tech/satchmo-diaries-part-one/)。
现在,我想要为 MyProduct 创建一个自定义产品详细信息模板,并且仅限于 MyProduct。我尝试在
/project/templates/product/product.html
“但是”中创建一个模板,该模板会覆盖商店中所有产品的模板,而不仅仅是MyProduct。我也尝试过:
/project/templates/product/detail_myproduct.html
/project/templates/product/myproduct.html
但这些似乎都不起作用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第一个猜测是正确的:templates/product/product.html。
如果 MyProduct 是这样写的:
并且它是在管理员中注册的:
那么您应该能够在管理员中创建一个新的 MyProduct,然后在产品/产品中关闭产品上的
myproduct
属性.html:或者如果您更喜欢在 ./manage.py shell 中闲逛:
You were on the right path with your first guess: templates/product/product.html.
If MyProduct is written like this:
And it is registered with the admin:
Then you should be able to create a new MyProduct in the admin and then key off of a
myproduct
property on the product in product/product.html:Or if you prefer messing around in ./manage.py shell: