如何从数据库加载通用视图的 template_name?
我有一个具有 template_name 字段的模型,并且有一个通用视图:
url(r'^/post/(?P<slug>[a-zA-Z0-9_.-]+)$', 'django.views.generic.list_detail.object_detail', {
"template_object_name" : "post",
'template_name': 'post_details.html'
}, 'index')
How can I Replace the template_name from 'post_details.html' to the template_name inside post?
I have a model that has a template_name field and I have this generic view:
url(r'^/post/(?P<slug>[a-zA-Z0-9_.-]+)
How can I replace the template_name from 'post_details.html' to the template_name inside post?
, 'django.views.generic.list_detail.object_detail', {
"template_object_name" : "post",
'template_name': 'post_details.html'
}, 'index')
How can I replace the template_name from 'post_details.html' to the template_name inside post?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个 template_name_field 参数。顺便说一句,您缺少查询集参数。它看起来像这样:
There is a template_name_field arg. By the way, your missing the queryset arg. It would look something like this: