Given that gae & django persistence layers are quite similar, I'm wondering whether someone has tried creating a wrapper? Say, could be useful for utilizing django.forms.ModelForm.
Are there any fundamental problems with this?
App-engine-helper provides limited support for this, but you're still dealing with thinly-disguised App Engine models. I'm not hugely familiar with Django's model framework, but the basic issue is that Django's model framework is simply too tied to relational databases to easily move to the App Engine backend.
You can use a variant of ModelForms, built right into the App Engine SDK, though - see here for details.
Django norel is better alternative to app-engine-helper. It is a much better abstraction that supports django queries (well many of them -- there is no JOIN support), foregin keys (no ManyToMany relations, though).
Django norel supports admin app (app-engine-patch doesn't).
What, you mean like the Google App Engine Helper or Google App Engine Patch?
The design of Django models implicitly assumes that you're using a relational database. Unfortunately, Datastore does not support all the features of a relational database. For example, there is no equivalent of a join query in Datastore. General transactions aren't supported either. As such, it would be really hard (if not impossible) to adapt Datastore to work as a drop-in replacement for Django models.
At 4:45 of this YouTube video, Guido Von Rossum briefly describes how you need to rethink the way you design your database to fit Datastore's model. The benefit is that you will be able to scale up very well. At 48:30, someone asks why the Datastore API wasn't designed to be more like Django models. Guido explains that the fundamental differences between Datastore and a relational database make this impractical. 13:20 also discusses this.
Related
Does anyone have experience in this topic? Is it fully incompatible or might it be possible to customize certain parts of the app to make it work.
multi-tenancy is not yet fully supported by Wagtail.
Although, as mentioned here in docs, there are some features that are supported.
You may find this blog helpful. Also here is a repository that implements basic features of multi tenancy with django and wagtail and you can play around with it.
Here are some other CMS (build on top of Django) you can try.
I think as long as there are no raw sql queries in wagtail's source code we are good to use django-tenents, the layer that django-tenets is working on is on top of django orm it self.
see wagtail-tenents
I have a Django project with a MongoDB, connecting through pymongo.
I've looked into several ORM(-like) layers, but none of them seem well maintained or supporting the Django 1.8 (mongo-engine only supports Django 1.5, mongokit is no longer maintained, and the other libraries seem to have no real community behind them).
So I think I'll be just using pymongo, which means that there is quite some things I'll need to implement myself, for example validation (checking that every document inserted in a collection has the required fields and field types).
How would I go about this?
Are there any example projects that I can take a look at?
I found this project which connects from Django directly to Mongo, but there is not much structure in it.
Use PyMODM. As the docs you linked to say, "PyMODM is an ORM-like framework on top of PyMongo. PyMODM is maintained by engineers at MongoDB, Inc. and is quick to adopt new MongoDB features. PyMODM is a “core” ODM, meaning that it provides simple, extensible functionality that can be leveraged by other libraries to target platforms like Django. At the same time, PyMODM is powerful enough to be used for developing applications on its own. Complete documentation is available on readthedocs in addition to a Gitter channel for discussing the project."
https://api.mongodb.com/python/3.4.0/tools.html
In my django application I have essentially joins ("__"). If I were to use Google App Engine, how would my app work in this instance? From what I've read, Bigtable doesn't allow this. Any advice on how to work with this?
Simple answer: it wouldn't.
You would presumably be using django-nonrel in any case. An extension to that, django-dbindexer, provides some support for emulating certain joins. But it's far from comprehensive. You generally need to architect your application in a different way to use the GAE datastore.
I understand that full django can be used out of the box with CloudSQL. But I'm interested in using HRD. I'd like to learn more about what percentage of django can be used with nonrel. Does middleware work? How about other features of the framework like i18n, forms, etc. Also does nonrel work with NDB?
The background here is that I've even using webapp2 and before that webapp and find them great until your project gets bigger. So for this project I'm interested to reevaluate other options.
The big limitation is that the datastore doesn't do JOINs, so anything that uses JOINS, like many-to-many relations won't work.
Any packages/middleware that uses many-to-many won't work, but others will.
For example, the sessions/auth middleware will work. But if you use permissions with auth, it won't. If you use the admin pages for auth, they use permissions, so you'll have some trouble with those too.
i8n works.
forms work.
nonrel does not work with ndb.
I don't know what you mean by "until your project gets bigger". django-nonrel won't help with the size of your app.
In my opinion there's two big reasons to use nonrel:
You're non-committal about App Engine. Nonrel potentially allows you to move to MongoDB as a backend.
You want to use django packages for "free". For example, I used tastypie for a REST API, and django-social-auth to get OAuth for FB/Twitter logins with very little effort. (On the flip side, with 1.7.0, they've addressed the REST API with endpoints)
According to this question:
Django on Google App Engine
The easiest way to get started with GAE/Django is with the Django non-rel bundle. However now that the latest Python/GAE SDK includes a build of Django, do we still need this?
What's the best-practice for getting started wth Django on GAE right now?
Thanks
Update: It seems that Web app2 is the easiest choice for new projects.
This guest article suggests that
"App Engine does come with some Django support, but this is mainly
only the templating and views."
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. Hence you can't use Django models, and hence, Django's model forms. What you'd have to do use use models derived from GAE's python db.Model(). Instead of using Django's ModelForm class for forms, you would use google.appengine.ext.db.djangoforms. Note, that's specifically for ModelForms, other forms work fine since they're not tied to the database.
I can think of two good reasons to use Django-nonrel:
1a) you have a existing project on Django. Using Django-nonrel would be the laziest way to go. 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.
2) You want to hedge your bets against GAE. Using Django-nonrel will allow you to switch over to MongoDB with very little effort, since Django-nonrel has a functioning MongoDB backend. The current Django-nonrel maintainers seem to be more interested in 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. 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.
If you do use GAE's native db API, the main benefit from Django would be the form validation. Otherwise, webapp2+jinja2+gae db.Models() would provide similar functionality to Django.