在 Django 中实现通用受保护预览
我正在尝试向 Django 管理添加某种通用预览功能。与 Django 内置的现场预览功能相反,此预览应该仅对具有特定权限的登录用户可见。
我的所有内容模型都具有相同的基类,它添加了已发布和未发布等状态。显然,未发布的内容不会出现在网站上,但编辑者仍然应该能够预览未发布的网站。
我在即将发布的 Django 1.3 版本中读到了有关基于类的视图,它可能非常适合以通用方式实现它。对于 Django 1.2,我似乎无法在不触及任何单个视图并添加特定权限检查的情况下提出解决方案。以前有人做过类似的事情吗?
I'm trying to add some kind of generic preview functionality to the Django admin. Opposed to Django's builtin preview-on-site functionality this preview should only be visible to logged in users with specific permissions.
All my content models have the same base class which adds a status like published and unpublished. Obviously unpublished content doesn't appear on the website, but editors should still be able to preview an unpublished site.
I read about class based views in the upcoming Django 1.3 release which might be well suited to implement it in a generic way. With Django 1.2 i can't seem to come up with a solution without touching any single view and adding specific permission checks. Has anyone done something like that before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信 Django 管理员已经为任何提供 get_absolute_url() 方法的模型的管理页面提供了“现场显示”选项。使用装饰器,应该可以跨模型以通用的方式做到这一点
希望这是信息丰富的(并且希望是正确的;)
I believe the Django Admin already provides a "show on site" option to the admin pages of any models which provides a get_absolute_url() method. Using decorators, it should be possible to do this in a generic way across models
Hope this is informative (and hopefully correct ;)