简体   繁体   English

我应该使用Django的contrib应用程序还是构建自己的应用程序?

[英]Should I use Django's contrib applications or build my own?

The Django apps come with their own features and design. Django应用程序具有自己的功能和设计。 If your requirements don't match 100% with the features of the contib app, you end up customizing and tweaking the app. 如果您的要求与contib应用程序的功能不完全匹配,则最终会自定义和调整应用程序。 I feel this involves more effort than just building your own app to fit your requirements. 我觉得这比仅仅构建自己的应用程序以满足您的需求需要更多的努力。

What do you think? 你怎么看?

It all depends. 这完全取决于。 We had a need for something that was 98% similar to contrib.flatpages. 我们需要与contrib.flatpages有98%相似的东西。 We could have monkeypatched it, but we decided that the code was so straightforward that we would just copy and fork it. 我们可以对它进行monkeypatched,但我们认为代码非常简单,我们只需要复制并分叉它。 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. 另一方面,使用contrib.auth执行此操作可能是一个糟糕的举动,因为它与contrib.admin和contrib.session的交互。

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 Plug(g)ables上 ,大多数都托管在Google CodeGitHubBitBucket上

Most of the apps in django.contrib are written very well and are highly extensible. django.contrib中的大多数应用程序编写得非常好,并且具有高度可扩展性。

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. 我认为扩展contrib应用程序时最好的部分是你并没有真正做任何hacky,你只是编写(主要是)常规Python代码来添加功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果我只想在条目下方添加一个简单的注释框,我应该使用Django的注释框架还是编写自己的注释框架? - If I just want a simple comment box below my entry, should I use Django's comment framework or write my own? 如何将django-avatar与我自己的用户模型一起使用,而不与django.contrib.auth.models.User一起使用 - How to use django-avatar with my own User model and not with django.contrib.auth.models.User 我应该使用自己的用户表还是使用django管理员生成的表? - Should I use my own users table or use the admin generated one with django? Django的update_object通用视图安全吗? 我应该扩展它还是为了安全起见? - Is Django's update_object generic view secure? Should I extend it or make my own for security? 在Django中存储电话号码时,我应该将它们存储为原始数字还是使用django.contrib.localflavor? - When storing phone numbers in Django, should I store them as an raw digits or use django.contrib.localflavor? 我应该使用什么类型的文件来保存我的应用程序信息? - What type of file should I use for saving informations for my applications? 我应该使用内置异常还是定义我自己的异常? - Should I use builtin exception or define my own? 在Django中获取自己的应用程序 - Get own applications in Django 有没有一种简单的方法可以将django的模板引擎用于django自己的视图,将jinja2引擎用于我自己的视图? - Is there a simple way to use django's template engine for django's own views and jinja2 engine for my own views? 我可以在GAE上使用django.contrib.gis吗? - Can I use django.contrib.gis on GAE?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM