且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

具有多个模型的一个应用程序与具有单个模型的多个应用程序

更新时间:2023-11-22 19:37:46

每个人有一个模型更好吗?Django 应用程序?

Is it better to have one model per Django-app?

可重用应用程序的关键思想之一是:做一件事,做好

One of the key ideas for a reusable application is: Do one thing, and do it well

如果一个应用需要多个模型(PostEntry、PostAuthor,如果是博客应用),这绝不是坏事.然而,标签、类别、评论代表不同的功能,理想情况下可以在其他上下文中重复使用,因此应作为独立应用分发.

If an app needs several models (PostEntry, PostAuthor in case of a Blog App) this is by no means bad. Tags, Categories, Comments however represent distinct features which ideally can be reused in another context and therefore should be distributed as standalone apps.

是否有***实践?

要了解一个好的应用程序组织,我首先要看看 Django 可重用应用程序约定.

To get a feeling for a good app organization I'd first take look at Django Reusable App Conventions.

那么您已经准备好迎接 James Bennett 在 DjangoCon 2008 (幻灯片).另一个关于同一主题的最新研究是来自 PyCon 的 Pluggable Django Application Patterns2011

Then you are ready for James Bennett's talk about Resuable Apps from DjangoCon 2008 (Slides). Another, more recent take on the same subject is Pluggable Django Application Patterns from PyCon 2011