

Ask HN: Choosing a Python framework for web development? - aneel99

Hi all,
I'm new to programming and started developing software using Python around 6 months back. I also know a bit of C#, C, JavaScript, HTML and CSS. Not an expert in any thing, still learning. Also, I'm not very good at Regular Expressions--this was a new-year resolution ;)
Now I've come across a dilemma and find myself completely stumped. I cannot figure what Python web-framework I should choose to start developing web-based software using Python. I've looked at the websites of Django, Pylon, CherryPy and WebPy--and I couldn't decide ;( Considering my naive skills I intend to choose a lightweight framework and a framework with which I can easily use JavaScript for client-side scripting (my biggest fear). I think I'm in a company of some very smart people here so I will really appreciate if you can help me in choosing an appropriate framework--considering my skill-set. Thanks in advance, fellas.
======
nostrademons
Start with Django unless you have a very good reason to use one of the other
ones. Very good reasons include

1.) Previous skills with Mako, SQLAlchemy, Paste, or any of the other
libraries that Pylons or Turbogears is based upon.

2.) Previous code in one of the above libraries

3.) Functionality needs that Django cannot satisfy in at least a couple of the
following areas: authentication, user models, multiple database support,
template extensibility, deployment. I say "at least a couple" because if you
just need one, you can import it like you would in any other framework. The
price is that many existing Django add-ons won't be aware of your choice.

Bad reasons include:

1.) "Django's only for CMSes." Not true; it works just as well for anything
that involves web apps, including AJAX apps.

2.) "It's not scalable enough." The Washington Post runs on Django; I doubt
you're going to get more pageviews than them.

3.) "My data doesn't easily fit in the relational paradigm." That's what the
import statement is for; you can hook any data source you want up to a Django
view.

4.) "Django's templating language is too restrictive." That's what template
tags are for.

5.) "I'm really doing a full-fledged AJAX app, not a website." You can output
JSON or XML data from a Django view as easily as HTML, and you're not limited
to any particular JavaScript library. (I actually think Django views are more
convenient for this than Pylons controllers; there's less boilerplate.)

~~~
jedberg
> 2.) "It's not scalable enough." The Washington Post runs on Django; I doubt
> you're going to get more pageviews than them.

Just FYI, the Washington Post does not use Django for their main page. They
only use it for small side projects.

At reddit we tried to use Django, but had to switch to Pylons because, lo and
behold, it wasn't scalable. Specifically, it has a problem caching templates
under high loads.

~~~
nostrademons
Interesting...that's very helpful to know. Did you try memcached? I've heard
Pownce has been doing just fine with Django + memcached, and they get a decent
amount of traffic.

~~~
mpc
That will be interesting to see. I really don't think Pownce gets anything
close to reddit's traffic

------
iamelgringo
If you're serious about learning web programming, here's a few thoughts before
you pick up the Django book and start wading through it:

Take a look at the HTTP protocol, and learn what it does before you start
diving in to web frameworks. You'll understand what's going on inside the
framework before you get started.

After looking at HTTP, try some basic CGI programming. Just google: Python CGI
Tutorial. CGI is a bit archaic, but it helps to understand why frameworks
developed, and what they're making easier.

Pick up MySQL or PostGress and learn some SQL and databases first. Web
frameworks are essentially an "easy" way to develop a GUI for a database. If
you don't know what the database is, or what it's doing, you'll be chasing
your tail learning a framework first.

It's worth mucking around with some *nix and apache. You don't really have to
do this first, but you're not going to be able to do too much with your web
app, because I don't know of too many companies that serve Django apps off of
Windows. It's all Linux or BSD hosting for Django pretty much. That means
knowing at least the basics of shell scripting and apache config files.

~~~
ianb
If you are inclined to start from basics, you might want to try this tutorial:
<http://pythonpaste.org/do-it-yourself-framework.html>

------
inklesspen
I prefer Pylons for many reasons. One of them is that SQLAlchemy is the single
most powerful SQL library I've ever used, and Pylons makes it easy to use
SQLAlchemy, while Django doesn't. This is just one example of Django's
reluctance to use superior outside solutions.

~~~
astrec
Actually there has been a SQLAlchemy branch for over a year. Last I check it
had stagnated - not enough interest.

~~~
inklesspen
It's a wonder why, when Django's form validation and admin panels require the
Django ORM, and last I heard, using the SQLAlchemy branch required extra work.

~~~
astrec
The SQLAlchemy branch was intended to seamlessly integrate with the model api
- in other words you needn't know it was there. I don't think it got too far.

Form validation is not tied to the Django ORM.

~~~
inklesspen
That's funny, because when I was going through the newforms code, it had a lot
of ties to the ORM.

~~~
astrec
And yet form validation is not tied to the ORM. The ORM is leverage where a
form is generated from a model, but that's not what you said.

------
tebeka
For me CherryPy hits the spot between "too much magic" and "too low level".
I've used many templating systems with it, found Make and Cheetah to fit my
mind the best.

~~~
tebeka
That's "mako"

------
big-j
One thing you might try is to start by writing some small CGI webapps/scripts.
Later on, it will give you an appreciation of what the frameworks are actually
doing for you.

Also, if you're not married to Python, and are looking for something really
simple and easy to learn, you might try Perl's CGI::Application (along with
some plug-ins).

------
gordianknot
Study the source of existing sites you like. Then start writing your own
Python framework upward to recreate (and fast transcend) them. Extensively
study the existing frameworks, especially when you hit a conceptual or
implementational roadblock. Understand everything you have to work with at
each step. Keep building up.

------
menloparkbum
I've used pylons and cherrypy, and did some massive rails things way back when
rails was still cool (2007). I prefer the cherrypy way of doing things vs.
pylons, but they are mostly aesthetic choices. Django is probably your best
bet unless you want something lightweight.

~~~
ardit33
I agree. For a simple web app, Django might be an overkill, that you might not
need. Cherry.py, is simple. Web.py is very simple also(not quite a framework),
but it also has poor documentation.

It is up to you, on what you want to do. If you are comfortable with writing
your own SQL, then Django is not going to be as useful as something more light
weight like cherry.py

------
gcheong
As you seem to be just starting out, I would suggest a ground up approach to
learning how to build web apps, choice of language being rather secondary
here. Have a look at:

<http://philip.greenspun.com/seia/>

------
pchivers
Some additional opinions...

 _Ask Hacker News: What Python web framework should I use?_

<http://news.ycombinator.com/item?id=129121>

------
jkush
web.py is a good one for learning more about Python.

------
jjguy
django's templating language is great for small projects, but their object
model is a disaster. I'd roll your own data access layer.

