不同型号共用一个ID列表

发布于 2024-09-28 13:01:34 字数 155 浏览 1 评论 0原文

在我的应用程序中,我添加了一个“Facebook 评论框”(在不同的页面上,针对不同的对象)。每个对象都有自己的评论列表,因此我需要为每个对象提供唯一的(整个站点)ID。

实现这一目标的最佳方法是什么:一个所有其他模型都将从中继承的抽象模型?具有外键关系的虚拟模型?你有什么想法?

In my application I've added a "Facebook Comment Box" (on different pages, for different objects). Each object has its own comments list so I need to provide a unique (across the site) ID for every single one of them.

What would be the best approach for achieving this: An abstract model, from which all other models will inherit? A dummy model with a ForeignKey relation? What are your ideas?

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

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

发布评论

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

评论(2

阳光下慵懒的猫 2024-10-05 13:01:34

您可能想要实现 GUID:

http:// www.codecommit.com/blog/database/are-guids-really-the-way-to-go

这是一个 django 模块,为您提供了一个“em”字段:

http://pypi.python.org/pypi/softwarefabrica.django.utils/

...您可以安全地使用它们在 URL 中——不会很漂亮,但对于评论和其他没有明显 URL 标题的东西,GUID 效果很好。

You may want to implement GUIDs:

http://www.codecommit.com/blog/database/are-guids-really-the-way-to-go

Here's a django module that gives you a field for 'em:

http://pypi.python.org/pypi/softwarefabrica.django.utils/

... you can safely use them in URLs -- won't be pretty, but for comments and other things without obvious URL-able titles, GUIDs work out well.

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