Saturday, 8th November 2008
After recently developing something in app engine and, generally liking it, I thought I would port over a new paster which quickly stole all the RAM on my slice - because, how hard could it be?
Now, first of all - pretty much everyone knows that (at least running app-engine-patch) Django’s models go out the window to use Google’s scaling monster, BigTable. This in turn screws up some of the internal things such as the form field ModelChoiceField (which I created an incredibly ugly work around for, which itself should be a post) but also removes the nifty shortcuts and you’ll have to rewrite a lot of code.
I use the pk shortcut a lot in this specific app, which is just the default auto incremental id field which MySQL uses - but in BigTable this shortcut doesn’t exist, so I just created this simple pk() function in my model to replicate it:
def pk(self):
return self.key().id()
I’m not sure if BigTable keeps the ID field on rows if you assign your own key, but I went with the default auto generating key.
This lets me keep my pk shortcut in my templates but you’ll have to use pk() in python code.
I’ve also added an alias for the Django save() function in my models:
def save(self):
return self.put()
This makes save() work exactly like put() in my views, which in my opinion makes everything a bit more clear.
Have you ported a Django app to App Engine, if so, what small fixes did it take to get it working?
theRealKiyosaki
It’s just a wonderful response
qwrt_
Dear Author luddep.se ! Very good idea