我应该使用 Django 的 contrib 应用程序还是构建自己的应用程序?
Django 应用程序有自己的功能和设计。 如果您的要求与 contib 应用程序的功能不 100% 匹配,您最终需要自定义和调整应用程序。 我觉得这比仅仅构建自己的应用程序来满足您的要求需要更多的努力。
你怎么认为?
The Django apps come with their own features and design. If your requirements don't match 100% with the features of the contib app, you end up customizing and tweaking the app. I feel this involves more effort than just building your own app to fit your requirements.
What do you think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这一切都取决于。 我们需要与 contrib.flatpages 98% 相似的东西。 我们本可以对其进行猴子补丁,但我们认为代码非常简单,因此我们只需复制并分叉它即可。 效果很好。
另一方面,考虑到与 contrib.admin 和 contrib.auth 的交互,使用 contrib.auth 执行此操作可能是一个糟糕的举动。 贡献会话。
It all depends. We had a need for something that was 98% similar to contrib.flatpages. We could have monkeypatched it, but we decided that the code was so straightforward that we would just copy and fork it. It worked out fine.
Doing this with contrib.auth, on the other hand, might be a bad move given its interaction with contrib.admin & contrib.session.
在构建自己的应用程序之前,我还会检查第三方可重复使用的应用程序。 许多都在 Django Plug(g)ables 上列出,并且大多数托管在 Google 代码,GitHub 或 BitBucket。
I'd also check out third-party re-usable apps before building my own. Many are listed on Django Plug(g)ables, and most are hosted on Google Code, GitHub or BitBucket.
django.contrib 中的大多数应用程序都编写得非常好并且具有高度可扩展性。
不太喜欢评论的运作方式? 对其中的模型和表单进行子类化,添加您自己的功能,您就可以轻松获得适合您的站点架构的工作评论系统。
我认为扩展 contrib 应用程序时最好的部分是,您实际上并没有做任何 hacky 的事情,您只是编写(大部分)常规 Python 代码来添加功能。
Most of the apps in django.contrib are written very well and are highly extensible.
Don't like quite how comments works? Subclass the models and forms within it, adding your own functionality and you have a working comment system that fits your sites schema, with little effort.
I think the best part when you extend the contrib apps is you're not really doing anything hacky, you're just writing (mostly) regular Python code to add the functionality.