简体   繁体   English

现在我们还需要django-nonrel GAE(据说)开箱即用支持Django吗?

[英]Do we still need django-nonrel now that GAE (allegedly) supports Django out of the box?

According to this question: 根据这个问题:

Django on Google App Engine Google App Engine上的Django

The easiest way to get started with GAE/Django is with the Django non-rel bundle. 开始使用GAE / Django的最简单方法是使用Django非rel bundle。 However now that the latest Python/GAE SDK includes a build of Django, do we still need this? 但是现在最新的Python / GAE SDK包含了Django的构建,我们还需要这个吗?

What's the best-practice for getting started wth Django on GAE right now? 现在开始使用GAE上的Django的最佳实践是什么?

Thanks 谢谢

Update: It seems that Web app2 is the easiest choice for new projects. 更新:似乎Web app2是新项目的最简单选择。

This guest article suggests that 这篇客座文章暗示

"App Engine does come with some Django support, but this is mainly only the templating and views." “App Engine确实提供了一些Django支持,但这主要只是模板和视图。”

non-rel is still seemingly your best bet. 非相关仍然是你最好的选择。 Although I'd caution you that further development and/or maintenance may not happen according to their blog . 虽然我告诫你,根据他们的博客,可能不会进行进一步的开发和/或维护。

Normal Django's models doesn't have a backend supporting GAE's datastore. 普通Django的模型没有支持GAE数据存储的后端。 Hence you can't use Django models, and hence, Django's model forms. 因此,你不能使用Django模型,因此,Django的模型形式。 What you'd have to do use use models derived from GAE's python db.Model(). 你需要做的就是使用从GAE的python db.Model()派生的模型。 Instead of using Django's ModelForm class for forms, you would use google.appengine.ext.db.djangoforms. 您可以使用google.appengine.ext.db.djangoforms而不是将Django的ModelForm类用于表单。 Note, that's specifically for ModelForms, other forms work fine since they're not tied to the database. 注意,这是专门针对ModelForms的,其他表单工作正常,因为它们不依赖于数据库。

I can think of two good reasons to use Django-nonrel: 1a) you have a existing project on Django. 我可以想到使用Django-nonrel的两个很好的理由:1a)你有一个关于Django的现有项目。 Using Django-nonrel would be the laziest way to go. 使用Django-nonrel将是最懒散的方式。 Rewriting models to GAE's models isn't too hard, but it could be a small pain, especially if 1b) you use a lot of existing Django components, and you'd have to go through all of them to update the models and forms. 将模型重写为GAE的模型并不是太难,但它可能是一个小小的痛苦,特别是如果1b)你使用了很多现有的Django组件,你必须通过所有这些来更新模型和表单。 2) You want to hedge your bets against GAE. 2)你想对抗GAE的赌注。 Using Django-nonrel will allow you to switch over to MongoDB with very little effort, since Django-nonrel has a functioning MongoDB backend. 使用Django-nonrel将允许您轻松切换到MongoDB,因为Django-nonrel具有正常运行的MongoDB后端。 The current Django-nonrel maintainers seem to be more interested in MongoDB. 目前的Django-nonrel维护者似乎对MongoDB更感兴趣。

Having worked with Django-nonrel, I've so far run into some reasons why it may be a bad choice: 1) No support for ancestor queries. 在使用Django-nonrel之后,我到目前为止遇到了一些原因,为什么它可能是一个糟糕的选择:1)不支持祖先查询。 There's an outstanding pull request for this though. 虽然有一个出色的拉动请求。 It won't be compatible with any other DB backend though. 但它与任何其他数据库后端都不兼容。 2) ndb is coming out, and seems like it'll have a few more benefits, that likely won't see support on Django-nonrel. 2)ndb即将推出,似乎还有一些好处,可能不会看到对Django-nonrel的支持。

If you do use GAE's native db API, the main benefit from Django would be the form validation. 如果你确实使用GAE的原生db API,那么Django的主要好处就是表单验证。 Otherwise, webapp2+jinja2+gae db.Models() would provide similar functionality to Django. 否则,webapp2 + jinja2 + gae db.Models()将提供与Django类似的功能。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM