Django for PHP Developers

Comparing the Languages

PHP has never been known for leading the cutting edge of language design but it's easy to get up and running and that is a big attraction for upcoming developers who just want to "get things done". If PHP's all you've ever worked with then maybe you think it's great. You've probably learnt a lot while writing PHP and you just take all it's little quirks in your stride. Django is written in Python and if you've never used it you've got some learning to do. Don't worry though you're gonna have a great time. Python is enjoyable to write, no brackets, no semicolons, whitespace is enforced and the language as a whole just feels like a dream come true after a few years in the PHP battleground.

Comparing the Frameworks

PHP has many frameworks and some of them are pretty good. I'm sure many people search Google day to day looking for Drupal vs Django or WordPress vs Django but you can't compare a Web Framework with something that is pretty much a completed product. So let's compare them in the context of some particular use cases.

SMALL BUSINESS WEBSITES

You're building a website for the local shop or your Dad's building company and to be frank you could pull it off in any technology but which product is going to be the cheapest to build, easiest to maintain and the most user friendly for the site authors.

Drupal

  • Has all the modules you're going to need. Web forms, galleries, notifications, slideshows and more. Drupal has modules for everything that's common in this niche.
  • Has pretty much solved content management. The UI is pretty dam good and most people can learn to author content without too much effort.
  • All your content types are managed in the database. This makes it super easy to create new content types with Drupal's powerful UI but it isn't so good when something goes wrong. There's no SCM on them bad boys.

Django

  • It's almost certainly going to take you longer for the basic stuff, hence cost the client more money and you probably don't need the additional flexibility.
  • You've got to write all your models in code which is probably overkill and a time waster for this project.
  • You get to use Python. It makes it easy to write clean and maintainable code. You've got great data structures, everything's an object and the Python API's are clean, well documented and easy to use.
  • You'll probably feel better about yourself.

Large Business App

You've landed a medium to large scale web app. They want to integrate with existing software, manage important business data and provide an internal company portal for their employees. The scope is wide and there are many unknowns in the project.

Drupal

  • Has so many modules that you'll probably find something similar to what you want. Unfortunately it will unlikely be perfect.
  • Extending other modules functionality can soon become cumbersome with hooks when you find yourself needing to add new relational data.
  • You have a great admin interface that you can build your custom features into. Viewing, sorting and manipulating data will be easy for the admins.
  • All your content types/models are managed through the UI. That may have been great to get things off the ground quickly but it won't be long until someone changes something on remote and not on local or you develop a feature locally and forget to replicate it on remote. Yes there are update hooks and D7's field API isn't bad but it's not great either.
  • Drupal 7 has a pretty good testing framework in simpletest but I find Python's built in testing a little more intuitive.

Django

  • You've got to write all your models in code but the additional time it takes is negligible in the scale of a big project and for the advantage of managing your models in code it's a good trade off.
  • With not too much work you can also generate a powerful admin interfaces and with apps like Django Admin available it's not to hard to put together a pretty sexy admin.
  • Extending and overloading functionality is easy. You can extend and replace models throughout the system without to much effort.
  • Testing with Python and Django are great. Python's standard libraries ship with their own testing frameworks which make writing tests almost seamless.

Conclusion

In conclusion, I used a few use cases to compare the two frameworks and I think it lays my opinions out pretty clear. If you're building a website for a small to medium business that involves many features common to the web such as forums, blogs, consuming API's, and a great way to manage content then choose Drupal. If you're building a a web app that requires many complex relationships, is heavily based around custom workflows and has a varying scope then choose Django. All that said, Drupal 8 is right around the corner and it's looking pretty awesome.

Comments

Permalink

@claudiu, that's a subjective comment. Drupal may not have started as a framework but it certainly provides a vast amount of reusable and modular functionality that can help with many different size apps.

Permalink

In my experience, the topic of to whether Drupal is a web framework only exists within the Drupal community; to those that actually use web frameworks, it doesn't really emerge as a question.

Permalink

@Andy, I tend to think you're probably right. I am however mainly participating in the Drupal community :-)

There are many of these types of posts on the net. What I've noticed is that they rarely discuss what I see as drupals weakest point. In my experience for anything but the simplest of sites the lack of a good upgrade path in drupal makes it expensive in time and money to keep up to date. While frameworks need updating I have found the process far less costly overall in django when compared to drupal. That coupled with the time it takes to tweak drupal modules to get what you want to me has led us to django for mos sites we build including some simple ones.

Permalink

@chad, are you comparing minor updates with a minor framework update vs a major update in Drupal? How easy will it be to upgrade from Django 1.x to 2.x? Drupal only make API changes between major versions and the core upgrade path should be pretty good. Contrib modules however is often not such a good story.

I am with Chad on this one. Minor updates on Drupal aren't that big a deal (although very frequent), but doing a major upgrade is a major pain in the ass. Especially when you start using things like custom content types, etc. Not to mention the constant module updates and security fixes that come out on a weekly basis, keeping a Drupal site current over a number of years is a very high maintenance proposition. At least from my experience :-)

Willer is a PHP framework, it was created based on ideas coming from other frameworks like Codeigniter(php) and Django(python).

http://williamborba.github.io/willer/quick_start/

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.