Live data from Hacker News

Why so many Python web frameworks?

bitworking.org

41–50 of 61 posts

Re: Why so many Python web frameworks?

#41
post #35

While we are at the topic of Python web frameworks, I seriously like Flask's design better than django's. True that django came out before SQLAlchemy or Jinja2 became popular/existed, but I would have loved it had they re-factored. Django is great, with good re-usable components, but I like Jinja2 more than Django's templating. The argument for SQLAlchemy is more on the lines of I would prefer a standard ORM compared…

First, it's quite simple to replace Django's templating engine with Jinja. And second, Django's ORM isn't quite the equivalent of SQLAlchemy; the latter is supposed to be a true universal ORM, while the former is more limited, but focusing on the most important parts for a Web app.

> First, it's quite simple to replace Django's templating engine with Jinja.

Yes, it is. But most of the applications are tightly coupled with Django's ORM(auth, for eg, which I use very frequently), and in the end, I end up maintaining two types of templates which I don't like.

> And second, Django's ORM isn't quite the equivalent of SQLAlchemy;

No, it isn't. But SQLAlchemy does what django's orm does, and then some.

I would prefer a compartmentalized model, where a web framework doesn't implement templating or ORM, provided a robust solution exists. The templating engine and ORM should be independent libs, and the web framework should glue them together, possibly adding a declarative layer above them(render_to_response, declarative ORM etc).

Re: Why so many Python web frameworks?

#44
post #35

While we are at the topic of Python web frameworks, I seriously like Flask's design better than django's. True that django came out before SQLAlchemy or Jinja2 became popular/existed, but I would have loved it had they re-factored. Django is great, with good re-usable components, but I like Jinja2 more than Django's templating. The argument for SQLAlchemy is more on the lines of I would prefer a standard ORM compared…

Totally agree with you on this. I think Flask is Django done right and I've been beating that drum for quite some time (see, for example, my comments on the settings file [1]).

The core devs claim that SQLAlchemy and Jinja weren't around at the time Django was developed, and that's fine. But in 2012, Jinja2 and SQLAlchemy are clearly better alternatives to Django's defaults. So why not incorporate them?

Django doesn't even have first class support for Jinja2 templates, let alone the python HAML variants.

What's ironic is that a few years ago Django was known for being loosely coupled when compared to Rails, which was considered monolithic ("my way or the highway"). Nowadays Rails is the flexible framework, allowing for different ORMs and templating systems, while Django is now the monolithic framework.

Don't get me wrong, I love stability. But when a great percentage of developers are using hacks to get around the default configuration system and to support excellent external libraries like Jinja2 and SQLALchemy, something is very wrong.

[1] http://news.ycombinator.com/item?id=3556929

Re: Why so many Python web frameworks?

#46
post #35

While we are at the topic of Python web frameworks, I seriously like Flask's design better than django's. True that django came out before SQLAlchemy or Jinja2 became popular/existed, but I would have loved it had they re-factored. Django is great, with good re-usable components, but I like Jinja2 more than Django's templating. The argument for SQLAlchemy is more on the lines of I would prefer a standard ORM compared…

We've been using Flask recently, and I do like the simple, no-nonsense approach. Our project is modest in its library needs, and it's nice to have a useful toolkit without imposing a heavyweight structure on our code.

There are significant limitations with some of these frameworks today, though. For example, lack of byte range/partial content support is bad news if you're serving large files (think multimedia).

We're still investigating options here, but WSGI doesn't seem ideally suited to working that way, and as far as we can tell quite a few of the "microframeworks" lack any kind of support for returning partial content automatically. The concern seems to be that WSGI would need the application to generate a complete response even if it was going to serve only part of it as a 206, because there's no standardised part of the routing set-up that says "I need these byte ranges from whatever full response you would have given me".

A common philosophy seems to be that such files should be served statically by your front-end web server anyway, but that is not sufficient in all cases. For example, you might need to process the request through your framework to generate the response on demand, implement access controls, or integrate with a custom logging/analytics framework.

[Edits: Trying to clarify key points.]

Re: Why so many Python web frameworks?

#47
post #35

While we are at the topic of Python web frameworks, I seriously like Flask's design better than django's. True that django came out before SQLAlchemy or Jinja2 became popular/existed, but I would have loved it had they re-factored. Django is great, with good re-usable components, but I like Jinja2 more than Django's templating. The argument for SQLAlchemy is more on the lines of I would prefer a standard ORM compared…

We're working with flask at the moment, and I have found it excellent. I really don't want to be bothered by anything to do with the web framework because I am already busy with the other stuff, and I've been able to ignore it all with flask because it is simple and lightweight it works.

We used pylons for the last project, and there are areas I still don't make improvements on because it is too much effort to get into it.

Re: Why so many Python web frameworks?

#50
post #19

Earlier quoted context omitted.

While some people may choose Django per default, there are also quite a lot of people that will choose Flask/Werkzeug, Pyramid or one of the less popular frameworks. The Python web development community is very much divided into different, although largely cooperating, groups. Django is definitely not the default choice when it comes to web development in Python and I doubt anyone seriously involved in the Django pro…

I would disagree with that fairly strongly. While there are other choices for specific niches, for most web development Django is the first thing that most Python developers will look at, mainly due to it's user base and libraries.

i would say django is the default choice for "yet another website" with some application logic sprinkled in. I wouldn't use it for anything other than a website serving up dynamic pages. I also feel I am fortunate to not have to build those websites anymore.
Post reply on HN