Easiest way to get django working on Google app engine? - django

I am trying to convert an old app-engine-patch project to use the out-of-the-box Django in Google app engine (without the "Cloud SQL" part, because I tried to set that up and it was a pain, and also required 'enabling billing' to try it out).
Are there good docs somewhere on how to write an out-of-the-box Django app on app engine? Possibilities seem to be:
appengine-patch. Old and unsupported since 2009.
google-app-engine-django. Deprecated since 2010.
django-nonrel. No longer supported by its original authors, last check-in is months ago.
Django with Cloud SQL. As I said, a pain to set up, and requires enabling billing to try.
You would think this question or this one or this one are duplicates, but the discussion on there is so old as to be useless.

I encountered the same problem when I recently developed a Django app for GAE. As far as I can tell, the easiest way is to use Django nonrel. The Google App Engine Django tutorial suggests this approach.
Now the second part of your question seems more geared towards long-term support of Django nonrel. You are correct that Django nonrel is no longer being supported. It looks like Google has an article on how to use Cloud SQL with Django, but they caution that Cloud SQL is experimental and subject to change.
Based on all of this information, you are left with a few options.
Use Django nonrel with the understanding that it may not be supported in the future. It is a risk, but the easiest solution if you want to get started quickly.
Use Google's Cloud SQL with Django with the understanding that it is experimental and subject to change.
Use Django, but do not use the ORM layer. This means you cannot take advantage of Django's admin site and a lot of 3rd party tools. This is the least risky if you are worried about long-term support.

I encountered the same difficulties as you. Anyways, as django-nonrel is no longer supported I chose going for Google Cloud SQL, since it has its free trial running until June 1, 2013.
All the current tutorials are for Django-nonrel so new tutorials are missing and setting up Django for Cloud SQL is not so obvious. That's why I decided to write this tutorial myself.

Related

Django, appengine and Django-nonrel

I want to create a web app using Django 1.5 or 1.6 using appEngine. I have read about as I have to do it and I have read about Django-nonrel which is very usefull to avoid the issues related with non-relational Database. Unfortunately I have read about the origininal creators project and they have left the project:
GoodBye
However I have seen new avaiables versions of Django AppEngine wich allow to use the 1.4 and 1.5 versions of Django
https://groups.google.com/forum/#!topic/django-non-relational/I06693ZPeME
After I have read every text I am a mess, do anyone redomended me use last version of django non-rel? can I use other framework? don't I use the last verion of Django?
Thank you.
I have developed a fairly complex web app using "normal" Django, not the non-rel flavour. For database storage I use Google Cloud SQL which is basically MySQL in the cloud. It works pretty good. There are some points to consider:
Google Cloud SQL has no "free plan", so it will incur a cost on your project.
Normal Django for GAE is currently at version 1.4 and lags a bit behind development which is if memory serves me right at 1.6. There is a version 1.5 of Django that comes with the GAE SDK but I did not get that work (I did not put any particular effort in it, just changed the Django version in my app.yaml file and it crashed).
As for the first bullet, there's now also a comparable product available from Amazon. I have not yet looked into it (I believe they do offer a free plan which might be interesting to try out), nor compared prices but that might be an alternative should Google Cloud SQL be too expensive. My yearly cost for Google Cloud SQL are between £150 and £200 which is not too bad.
My reason for choosing normal Django over non-rel was basically twofold:
The non-rel project appears abandoned.
The non-rel product is "crippled" in functionality according to some of the docs I read about it and you will not be able to use all of the pre-baked goodies of Django.
I have been working on this project for 7 months now and I find Django on GAE with Google Cloud SQL very stable and productive environments. FWIW, I use PyCharm which has a one click deployment feature which makes deploying my product an absolute breeze. I've been working on IT projects with various technologies for quite some time and the combination of PyCharm, Python, Django, GAE and Google Cloud SQL would be at the top of my list of productive environments.
Of course there are other Python frameworks to consider, like Flask which allow more of a best-of-breed approach but I have no experience with them.
Hope this helps.
I'm using django-nonrel 1.4, though I haven't updated to the latest build yet. It's running smoothly for me.
You do need to recognize that if you use django-nonrel, you have to live by the rules of the GAE HRD, especially the eventually consistent results, and the limited query capabilities.
Django-nonrel is definitely not abandoned! I am using the 1.6 version with much success at Docket Alarm and it is still being actively maintained.
Here are the up-to-date links to the project:
Docs
GitHub
Discussion group

Is porting a Django app to GAE still an option?

I have started a month ago with GAE and have successfully deployed our current startup via Flask on GAE. It works fantastically well. Now being all too exited about GAE, I am thinking about porting a couple of my older Django apps on GAE as well.
To my surprise the documentation of it is surprisingly inconsistent and partially contradicting.
The official google page recommends using django-nonrel, which itself is already disconstinued.
Django 1.5.1 seems not even to be supported yet on GAE, neither is it clear to me how to use Django 1.4.3 on GAE.
I also found this more recent solution that utilizes Django and Google Cloud (Mysql on cloud) instead of the high replication datastore. Not sure if this is a good way to go since its still experimental and subject to "breaking changes" in future. (It also doesn't seem to include any free tier, unlike high replication datastore)
I was expecting Django - as perhaps the biggest python web frameworks - to have a far better documentation or tutorials about how to do deploy it on GAE. So I wonder if its even worth it sticking with Django on GAE anymore.
If I am meant to make manually my own models and adjust my queries in Views by utilizing ndb anyway, I could as well stick with flask+Jinja2, why should I use Django, where I can't even use it's ORM anymore? Or am I overlooking something?
Thanks,
There's nothing on the link to the allbuttonspressed blog that implies it is discontinued. On the contrary, the page says that even though they (as the original maintainers) are pulling out of the project, it has been taken over by a new maintainer. That's what often happens in open-source projects.
As for Cloud SQL, there is a dedicated page on the App Engine documentation which explains in detail how to get this up and running. The Cloud SQL API itself is, it's true, still in "experimental" status, but again that's just what Google does. App Engine itself only came out of "experimental" last year.
As for why you should stick with Django, that's up to you of course, but both of the above solutions will give you Django forms, the admin interface, templates, and URL routing, and some or all of the ORM syntax.
There's some work going on in maintaining django-nonrel, though the Allbuttonspressed blog is starting to get pretty out of date. You'll find more up-to-date info in the django-nonrel mailing list on Google Groups.
I believe it's been updated to at least Django 1.5, but I'm personally still running on 1.4. The documentation is extremely lacking. You'll have to figure out from the mailing list the appropriate branch to use to get support for the latest django version. However, it's there and it's working.
Django + CloudSQL will likely be the least-coding route to port your app to GAE.
Django-nonrel gets to take advantage of the HRD, however, many apps written expecting SQL behavior will need to be extensively rewritten to support the HRD behavior properly.
As an example, I've tried running django-registration on django-nonrel. On first look, it seems to work fine. But on deeper inspection, there's issues like being able to register the same email address to more than one user on HRD. You may find similar issues with other apps, or just the inability to run at all, given that the HRD doesn't support many-to-many relations, as well as slightly-more-complex queries.

Django Admin site and Forms on AppEngine

i'm developing a web site hosted on AppEngine and wanted to use Django for some tasks. I've read these two answers:
Django on Google App Engine
Django and App Engine
But those are pretty old, and my question is a little more specific. I've taken a look at django-nonrel and seems good, but i've not used it and cant affirm anything.
So, the question is. Can I use the Admin site and the forms from Django with this package? If not, do you know any other patch that allow me to use them?
Thank you very much!
If you use django-nonrel, then you can use the Django admin site but it will be limited to the types of queries you can do on app engine. I personally found it easier to code my own simple admin interfaces that to type to make things work in Django Admin.
Regarding forms, regular Django Forms and ModelForms work quite well.
Yes, you can (both Admin and forms).
(definitely) :)
I installed djangoappengine 3 months ago and work on it daily under Eclipse (Windows).
If you have some expericence with Django it should be easy, I faced much more problems with Eclipse integration, but nothing unfeseable (even for a newbie - as I'm still).
You just have to start from here:
http://www.allbuttonspressed.com/projects/djangoappengine#installation
Be careful anyway: there are some limitations due to the Datastore capabilities.
A lot of work has been done to circumvent them (dbindexer, specifics decorators...) and if you're planning to develop an app from scratch you will find your way (keeping " noSQL " in mind) but if you plan to migrate a plain vanilla SQL app, it may cause you some pain...
Last point: instances handling Django and all its libraries may be long to start with App Engine ; an issue to consider:
http://code.google.com/p/googleappengine/issues/detail?id=1695
Hope it helps.
Florent

Running Mezzanine on App Engine

I am looking for a blog solution to run inside a Django project deployed on the Google App Engine. After a bit of review I decided to try out Mezzanine v0.11.3. I've overcome the hurdle of getting it in project using the advice of others deploying on App Engine at this link: http://groups.google.com/group/mezzanine-users/browse_thread/thread/c8b13c41a3168c94.
Mezzanine is now showing up in the Admin, but clicking on Blog posts leads to a multi-table inheritance failure. I believe that this is due to multi-site support functionality in Mezzanine via use of the Django sites framework.
Has anyone overcome this issue? I'm going to try to use django-dbindexer but I'm not confident it will work.
*Update: as far as I can tell, the folks at AllButtonsPressed don't have any magic solutions to work around ManyToManyField issues yet, so I think that option is dead.
If no one knows a work around, do any of you know of a good blog solution I can run inside a Django project on the App Engine?
*Update: found this post Integrating Blogger into a Google App Engine App. Will investigate if this solves the problem.
*Current Status:
I have not been able to solve this problem and I don't think it is currently solvable. Thought I would share what I found through my investigations though; maybe someone out there can carry on and come up with a solution.
Options tried:
Bloog
I looked this over but it is a Python
solution, not a Django solution and I
didn't want to do the work to turn it
into one
Byteflow ( https://bitbucket.org/piranha/byteflow/wiki/Home ) notes:
designed to be standalone, will need a
lot of edits to settings.py,
inclusion of 12 additional apps and
overrides on account settings plus
hand tuning at every upgrade.
AppEngineBlog ( http://code.google.com/p/appengineblogsoftware/ ) notes:
written in appengine specific code,
not maintained, no example sites
available to see how it looks
Coltrane ( http://code.google.com/p/coltrane-blog/source/browse/ ):
simple blog constructed from standard
Django functionality no development
or support, basically need to use
this code as a way to develop your
own blog and go from there
Flother ( https://github.com/flother/flother ):
found via Coltrane comments, probably
embeddable without too much trouble,
requires 8 additional apps,the photos
and places components have
ManyToManyFields that would have to
be re-written or these components
disabled
Blogger API ( http://code.google.com/apis/blogger/ ):
use Blogger at whatever location you
wish to gain fully functional
blogging capabilities, then use
Blogger API to deliver content to any
other site you wish to display it
Flother came close to what I need but there is still a fair bit of uncertainty and effort there. I'm proceeding with the Blogger option as the only viable choice for me at this time.
Well, as far as I can see, there is no way to get Mezzanine running on GAE other than wading into the code and ripping out anything relating to a ManyToManyField (Sites support, Photos and ... something else. Can't remember what).
The only thing I could find out there that has the potential to be added to an existing project, uses only portable Django code (app engine specific) and runs on App Engine is http://www.allbuttonspressed.com/projects/allbuttonspressed . I haven't actually tried to integrate it yet because I'm going to see if the Blogger solution works.
I've been using bloog for two of my blogs without any serious troubles so far - there are few little quirks that make it mildly unpleasant sometimes but nothing that's been a deal breaker.
I use the Blogger solution and it works fine, especially if you're only one person and you run the whole site.
The problem comes when you want to others to help you out. Now every css and design decision needs to be sent to a programmer who hacks away at django templates. A CMS with a real WYSIWYG editor would allow you to ship off that work to marketing/design people and let you focus on the fun stuff.
I came across a decent review of the various blogging engines for Django, however, it's unclear how well they each integrate with GAE.
I have deployed Mezzanine/Cartridge in GAE succesfully but I have not documented it yet in github or something like that. It works using python 2.7 of course and django 1.5. Additionally it works with Google Cloud SQL, and the local file system GAE provides. It additionally works with google gmail facilities. For thumbnailing I am using local GAE functionality.
It requires several additional libraries like boto, but it works well.
See a short demo in midevocional365.appspot.com/

Django on Google App Engine

How much of a pain is it to run a Django App on App Engine? Also, does the Datastore work as-is with Django?
I spent some time trying to answer the same question... it seems to me that the most difficult thing to transfer to GAE are django's models... in the sense that they require various modifications and rethinking, mainly because GAE's backend is not a standard relational DB, but google's BigTable. I found a nice intro to this here:
http://www.youtube.com/watch?v=rRCx9e38yr8
Anyways, it's worth downloading one of those 'patches' and have a go with it!
For me the best solution is the 'app-engine-patch'. I downloaded the sample project and it worked straightaway! (Mind that you need to have GAE's SDK installed separately) A killer-feature for me is the fact that the django-admin and many other classic django functionalities have been ported too!!!
http://code.google.com/p/app-engine-patch/
The documentation is still quite minimal in my opinion, but it's good enough to get you going. It'll help you to skim though the official GAE docs though!
Just Yesterday (depending on your time zone), Google released a new SDK for Python on Appengine that supports django 1.0 out of the box.
You need to use django-nonrel (source).
You will still find loads of issues:
Many2Many relations not supported
Fake joins increase number of queries
App Engine doesn't allow any python lib with socket or C dependencies (sentry, lxml...)
You can try to get early access to CloudSQL.
Otherwise you are not constraint to use App Engine, you can think about using:
Heroku
Gondor
Cheaper and more control with support requirement files like pip.
31.01.2012, Google released App Engine 1.6.2 that supports Django out-of-the box.
App Engine includes version 0.96 of Django out-of-the-box, but it is quite crippled.
App Engine Helper and app-engine-patch supposedly fix this problem to some degree, but I haven't tried either myself.
http://code.google.com/appengine/articles/appengine_helper_for_django.html
http://code.google.com/appengine/articles/app-engine-patch.html
The amount of pain depends on how much existing code you want to reuse. Unfortunately because of the Datastore does not support SQL, you often cannot just take any django-pluggable app and use it on your GAE project.
App-engine-patch http://code.google.com/p/app-engine-patch/ looks to be ahead of the other django helpers in bringing the standard applications (Sites, ContentTypes, Flatpages) over to GAE. I have used app-engine-patch on several gae projects, and once you understand how to port a django-sql model to a django-gae model and converting sql to datastore queries things can be done very quickly - but there is always a learning curve.
appengine-helper tries to bridge the Datastore gap by providing a model so you don't have to change your model superclasses, but I've found that you end up having to change ManyToMany relationships and any sql anyway, so the advantage ends up being minimal. ae-patch has a roadmap to try to provide an ae-datastore backend, but it probably won't happen for a while.
Google has now launched their Cloud SQL storage. That is actually MySQL 5.5 in the cloud. IMO that's a very nice way to migrate your Django app into the cloud. They have a free trial up to June 1, 2013.
If you need some tips how to set up your Django project for Appengine and Cloud SQL I've written a tutorial for that.