When using Google App Engine with Django-nonrel, is there any way to take advantage of the Async Datastore API when I declare my model classes with the Django API?
When using Google App Engine with Django-nonrel, is there any way to take advantage
Share
Ok, I’ve investigated a bit more and found an alternative way to deal with having a Django Model (i.e.: all Django features there) and still having access to the async API…
Mainly, using the datastore directly:
and I already had methods to convert all my models to/from a json dict, so, it was mostly a matter of discovering how Django-Nonrel did it behind the scenes:
E.g.:
Considering a ‘Project’ class with to_json and from_json methods (i.e.: create from a dictionary)
For doing a simple query (it seems Run() will do the work asynchronously, so, one could do the query.Run() and later start another query.Run() and both would work at the same time):
Now, using the API to get an object asynchronously:
So, it’s possible to retain the model with the Django structure and when needed some wrappers do the needed work asynchronously.