I'm vaguely yearning for a simpler framework than Django

August 28, 2013

I was going to say that this entry was about my disenchantment with Django but that isn't really accurate. Django works fine for what it is (although there are rough edges), it's just that it has a bunch of complexity and a certain amount of magic and (more importantly) it feels like a vast overkill for what I periodically want to do. The drawback of batteries being included is that they weight a lot.

(In a metaphorical sense. I'm not worried about Django's resource usage.)

In a way, the problem is that there is both too little and too much for a simpler framework to do. To really take a burden off the developer, you need:

  • templating.
  • form display, validation, and redisplay (including things like protections against CSRF).
  • URL routing.
  • some sort of database mapping layer.
  • some way to use database models outside of the web application itself, to enable cron jobs and commands and so on.
  • an optional layer to map database entries into forms and vice versa (which should be security smart).

(In a modern web framework you probably also want support for JSON service endpoints for frontend JavaScript or the like. Arguably that's like forms (and their database mappings), just without the complex HTML in the middle. Unfortunately I have very little idea what this should look like since I have quite little experience with frontend JavaScript.)

Given that this is most of what Django covers, I'm not sure that any framework (or set of framework components) that covers this is really going to be 'simple'. Especially unlikely to be simple is the bridge between database entries and forms, but it's also a very important component if you actually are working with a database.

(I've been thinking about this partly because my Django modularity design puzzle keeps rattling around in the back of my mind. It's quite possible that I won't need to use any of Django's powerful features in the eventual web app, which in theory means I could write it with a simpler framework instead of trying to fight how Django wants me to do everything.)

PS: pragmatically, I should go through eg Eevee's discussion of Python web development frameworks and read the documentation for the various frameworks to see how they cover these areas.


Comments on this page:

From 54.240.196.185 at 2013-08-28 11:39:56:

I don't think there is anything that gives you just those kinds of features. It really does seem to be a question of just a tap or the entire kitchen sink.

That said, there are some common and relatively mature components you can add to the lightweight frameworks instead, for example Flask uses Jinja2 templating, Flask-SQLAlchemy gives you your database abstraction (produced by Armin, Flask's developer), and the plugin Flask-WTF gives you an easy hook into WTForms and seems to be considered to be a first class citizen.

From 217.27.32.207 at 2013-08-29 06:29:15:

After short tests of a handful of frameworks, I ended up using web.py. It handles what you listed above, and allows me to actually write web apps in Python -- meaning that it does not try to redefine everything. I would suggest that anyone that uses any other Python framework, invests a few hours playing with web.py, even just for comparison and reference.

-- Marios Zindilis

Written on 28 August 2013.
« An example GNU Readline quoting function
A new piece of my environment: clearing the X selection »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Aug 28 00:38:03 2013
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.