26 10 / 2010

From GAE to Django

For the last few months, I have working in Google App Engine. It was a great place to start learning how to code.

You should try GAE for a couple reasons:

Free

There is a threshold where Google starts to charge you, but it’s rediculously high. We didn’t even pass that point with Dotty-dots

Simple setup with Django .96 

You can get started messing with Python, HTML, CSS very quickly. Using Google App Engine was an incredible resource that will put you on the right track.

But…

Once you outgrow those baby steps, it makes sense to move over to straight Django with your own hosting.

Power

Django’s latest release is 1.2.3. A lot has changed since .96, and you’ll probably want to take advantage of those functions and changes.

Django comes with Pagination! (Massive GAE headache)

Customization

Because of GAE’s setup, you CANNOT use most Django 3rd party apps, they must be wrestled into submission. For someone as inexperienced as me, this was just throwing fuel on the “I don’t have a clue what I’m doing” Fire.

#Advice: Avoid adding fuel to that fire.

You can try Django-nonrel and setup a modified, more recent version of Django to run on GAE. However I also ran into compatibility issues that seemed to pop up every other day. 

Ultimately by using GAE, you are outsourcing your server issues to Google at the price of customization. After the last few months, it became clear that I’d be happier with straight Django & pay $20/mo for my own hosting, than continue trying to reinvent the wheel - or Pagination.

Before you start a serious project on GAE, read “When App Engine Went Wrong.” Thanks to John Speno for the article!

21 10 / 2010

Day 2 Mystery Project - What are you good at?

In the last 24 hrs, I’ve worked out the site functionality & set up the project using Google App Engine & Django-nonrel. I have the models started, but will need to flush those out today, along with the views. 

Yesterday I asked, “What do you want to learn?” Today, a different question:

What do are you good at?

For this question, you do not have to be limited to technology. Ex. Things I’m good at, or knowledgable of:

  • Motown music
  • Roasting chickens
  • Tennis
  • BBQ
  • Local business marketing
  • Amateur photography
  • Evernote

What are you guys good at?

22 9 / 2010

Update 2: Django 1.2.3 on GAE

Thanks to Thomas Wanschik for telling me about his project to get Django running on Google App Engine. If you missed it, his comment to the last update was:

You can use django-nonrel in combination with the backend djangoappengine. Then Django’s User class will work even on App Engine :)

See 
http://www.allbuttonspressed.com/projects/django-nonrel
and 
http://www.allbuttonspressed.com/projects/djangoappengine

With the django-dbindexer you even can use all Django filters i.e. User.objects.filter(name__iexact=’YonDaime’). 
See http://www.allbuttonspressed.com/projects/django-dbindexer

Following his advice, I went through the installation on djangoappengine, and now have a pure Django project running on GAE. Models are not a funky GAE/Django mix as before, and Django applications run right out of the box.

Thanks again Thomas! This is huge!

20 9 / 2010

Update: Django 1.2.3 on GAE

After a few days of tinkering with Django 1.2.3 on Google App Engine, I decided to go back to a normal GAE setup for Buswheel. The simple reason: 

In GAE, you cannot use the Django User class.

Therefore you’d have to tweak every Django application to fit the BaseModel model. I could be totally wrong, and I’d love for someone to correct me on this.

15 9 / 2010

Django 1.2.3 on Google App Engine (GAE)

Here are the foolproof steps for starting a Django 1.2.3 project on Google App Engine. 

1. Create a new application in GAE Launcher. In this case our application is demo.

2. Download & Unpack the GAE- Django helper into the same folder where your demo folder is stored.

3. Remove the GAE Application Folder created by the Launcher. In this case the demo folder.

3.1 The reason is GAE Launcher hardcodes the location of the demo application,which you can’t change within the Launcher application.

3.2 Rename the appengine_helper_for_django folder to the name of your Application, demo.

3.2.1 This will allow Launcher to still look to this location for the demo Application.

4. In the new app.yaml, change the application name to demo, or the name of your application.

5. Open Terminal, and install Django into the new application folder.

cd my_project/
svn co http://code.djangoproject.com/svn/django/trunk/django/

6. Run the application in GAE Launcher

7. Go to localhost:808x to make sure, “It worked!”

*Know Django & GAE use the term Application in two different ways.

GAE application  == Django Project

Django Application is a part of a Django Project which can have multiple applications


8. Create a Django Application within the project

8.1 Add os.path.join(SDK_PATH, ‘lib’, ‘fancy_urllib’) to /appengine_django/__init__.py

8.2 Create the Django Application src

 

python manage.py startapp src

8.3 Ignore the WARNING. In src, you’ll find the models.py & views.py

 

9. You are done!