将变量传递给 Django 注释视图

发布于 2024-07-20 06:20:55 字数 508 浏览 4 评论 0原文

好吧,我知道我问过类似的问题,但我觉得这希望有点不同。 我正在将 django.comments 集成到我的应用程序中,并且我使用它的次数越多,我就越意识到它最终可能不值得我花时间。 除此之外,我已经设法将验证码添加到我的评论中,并且我了解到自定义表单是一个糟糕的主意(隐藏蜜罐非常困难,据我所知需要 JS 来隐藏。可惜。)。 不过没关系,我已经成功地使用它了。 然而,评论的模板(预览和发布)令人沮丧。

当用户被发送到预览或发布模板时,我希望具有动态数据的侧边栏仍然有效,但事实并非如此。 我是否必须覆盖/重写评论视图才能将数据推送到这些视图? 到那时,我似乎正在重写评论系统的主要部分,在这种情况下,编写自己的评论系统几乎是有益的。 我非常愿意这样做,并且完全理解我无权获得 Django 的完美评论系统。 我只是想确保我的想法是正确的,如果我想要的不仅仅是从评论视图中得到的东西,重写它们是我唯一的途径。

当然有人找到了更健康的方法,所以我想我应该对观众进行民意调查。 有什么想法吗? 如果您需要更多信息,请告诉我!

Alright, I know I've asked similar questions, but I feel this is hopefully a bit different. I'm integrating django.comments into my application, and the more I play with it, the more I realize it may not even be worth my while at the end of the day. That aside, I've managed to add Captcha to my comments, and I've learned that customizing the form is a terrible idea (hiding that honeypot is stupidly difficult, and from what I can tell requires JS to hide. Pity.). That's alright though, I've managed to work with it. However, the templates for the comments (preview and posted) are frustrating.

When a user is sent to the preview or posted templates, I'd like my sidebar's that have dynamic data to still be functional, however they're not. Do I have to override/rewrite the comments views to push data to these views? At that point it seems like I'm rewriting a major chunk of the comment system anyway, and it'd almost be beneficial to just write my own in that case. I'm more than willing to do that, and totally understand that I'm not entitled to a perfect comments system from Django. I just want to make sure I'm thinking right, and that if I want more than what I get from the comment views, that rewriting them is my only path.

Surely someone's found a healthier way though, so I thought I'd poll the audience. Any thoughts? If you need more info, just lemme know!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

×眷恋的温暖 2024-07-27 06:20:55

侧边栏中的动态数据就是模板标签的用途。

绝对没有必要搞乱内置视图 - 只需定义标签并将它们添加到您的模板中即可。

Dynamic data in sidebars is what template tags are for.

There's absolutely no need to muck around with the built-in views - just define the tags add them to your templates.

一直在等你来 2024-07-27 06:20:55

我也使用模板标签。 Django 中的模板实际上仅用于显示数据。
我认为 Django 相信设计师和开发人员之间的分离。 因此,他们强调模板应该足够简单,以便网页设计师可以使用。 (Photoshop 人员)

因此,只要您不需要复杂的功能,只需将信息传递给过滤器并让它进行数据操作并返回您需要的最终字符串。

I user template tags as well. Templates in Django are truly for displaying data only.
I think Django believes in separation between the Designers and the Developers. So, they are enforcing the idea of templates should be simple enough for web designer to work with. (the photoshop guys)

So, as long as you don't need complected functionality, just pass the info to a filter and have it do the data manipulation and return the final string that you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文