New Website and Switch to Django16 Jan 2013
This is my first blog post at my new website lyonwj.com. WilliamLyon.org has been shuttered. The overall design of my new site is very similar - the only real change is under the hood. I chose to switch to Django (from web2py) for my web projects. And that's what I'd like to talk about today - my impressions of web2py vs. Django. Both are excellent full stack Python web development frameworks. Both come batteries included (although it seems web2py has more functionality out of the box). I don't think I could say that one is better than the other - they are both great.
Why switch to Django then? Mostly because I felt having Django experience would be a better career move. It seems there are many more Django projects out there than web2py projects, and more companies looking to employ Django developers. This was the initial impetus for me, however once I started learning Django I started to notice some subtle differences. Full disclosure: web2py was the first web development framework I learned and I have only built a handfull of small projects (like this blog / project portfolio site).
The documentation for both web2py and Django are great - there is a free web2py book with tutorials and documentation as well as a cookbook written by the main developer. The Django documentation is also great and includes a few tutorials. The Django book is also great, however somewhat out of date. It was written for 1.1 and now 1.5 is just around the corner. An update to the book would help me appreciate things like mod_python is deprecated BEFORE I try to configure it with Apache.
As I mentioned earlier, web2py was the first web development framework I learned. I was also relatively new to Python at the time, so the learning curve for a framework was important to me. I suppose I was somewhat intimidated by Django and that led to my choice to pick up web2py. web2py was VERY easy to learn. I read the documentation I mentioned above and the cookbook. After that I was ready to build simple webapps. Switching from web2py to Django was also very easy - things made sense, but I suspect only because I was familiar with those same things via web2py. Having done some iOS development, the MVC model wasn't completely new so that helped. I should point out that Django uses a slightly different interpretation of MVC (MVT) but that also makes sense if you are familiar with MVC.
web2py has a web-based IDE, which was GREAT to have as a beginner. The IDE is completely optional however, and once I figured out what I was doing I didn't use it much (gimmie vim and a command line). Both have shell interaction (mostly Django's manage.py). The organization of projects in both make it very easy to plug-and-play apps and to use version control for individual apps. One important difference to note is web2py's approach of "implicit" vs. Django's approach of "explicit". While learning web2py I was often wondering how/why certain things just seemed to work, with Django most of these things need to be explicitly imported and configured. Personally, I feel this leads to a deeper understanding of what is going on. Others would argue that this allows the developer to focus on their project and not the framework. Both points of view are valid. web2py's template language seems to allow for more Python expressions than Django. The Django approach is to simplify the template language for designers to work with, leaving the model/view for the developer. web2py's internationalization is AWESOME and very easy to figure out / use. I haven't yet played with the Django equivalent of this. The final difference I will make note of is Django's ORM. Building models in Django is as easy as creating a class that extends models.Model and every field is an instance of a model field class (such as CharField, TextField, etc.). This is somewhat different than web2py's approach of defining a db table (db.table_define(xxx)), and I found the Django way easier.
The bottom line is that both Django and web2py are great full stack web development frameworks. I'm not aware of anything that can be done in web2py than can't in Django and vice versa. Personally I found web2py easier to learn and am glad I started there. I would love to see more web2py projects and job opportunities out there, but for now I'm switching to Django for the career possibilites.