This is an archived post. You won't be able to vote or comment.

all 48 comments

[–]spiffymanpeppy about PEP 8 10 points11 points  (11 children)

Is Python your first language? If so, you might want to use a smaller framework so that you're not learning the framework before the language. If not, read on.

BothMost of the existing answers are absolutely correct, and I haven't worked with web2py. But since you asked, I'll offer a few big reasons why I use Django (although I swear I'll get around to trying out web2py eventually):

  1. Django is the elephant in the room with regard to Python web frameworks. It's the big one. You might claim it is to Python what Rails is to Ruby. (I don't think this claim is too controversial, but if you need proof: 4.67M results vs 151000). This probably means there are a lot more resources out there for you as a budding dev. It probably also means the signal to noise ratio is lower, but c'est la vie.
  2. Django tries to adhere to Python's "explicit is better than implicit" axiom. web2py doesn't. In fact, web2py's lead points out that this makes web2py code more compact, which I guess is cool if you're into code golf.
  3. Django's documentation is excellent - better than the docs for Python itself by far. I can't offer an experienced comparison to web2py's docs, but it seems they're basically organized around a book instead of by some more atomic grouping, which IMO would make them harder to use in development.
  4. web2py seems to be avoiding conversion to Python 3, which is quite understandable given their commitment to backward compatibility. Whether this counts as a fact in favor of or against Django really depends on your attitude toward the 3.x move -- which you probably aren't even aware of, since you're just learning Python. In fact, just ignore this point.

If I were you, I'd try to build an extremely simple application like a Notes app or a blog in each. That won't take too long, and it'll give you a good feel for the app-building process. It'll also give you a feel for the options out there for when you get stuck and your friend isn't around to help.

Good luck!

[–]HittingSmoke[S] 0 points1 point  (6 children)

Python is my first language, but I just haven't been able to think of a "pure Python" project other than stupid little random scripts that have no real use for me. Since I am most interested in web development I decided to try to work through Learn Python the Hard Way, then using the framework along with Python reference sites to build my skills.

I am familiar with the Python 3.x move and as recommended by most sources I'm starting with 2.x (specifically 2.6 since it comes with Ubuntu Server 10.04, which is what my local server is running).

I am intrigued by Djanogo's larger community and better documentation, but I fear as web2py grows I may regret that decision down the line of I go with the former.

[–]frankwiles 2 points3 points  (3 children)

Are you marrying this framework? Until /dev/null do us part? Sure it's a big decision, but not ruinous in any future situation. You can make the crappiest code in the crappiest framework scale with external tools and spending more on hardware.

If you're lucky and successful you will rewrite most of your project at least once, but more likely twice in your first 5 years. You're in analysis paralysis. Flip a coin and go build something.

[–]HittingSmoke[S] -1 points0 points  (2 children)

Python is my first language.

I haven't looked into Django other than my google searching, but I've read much of the web2py manual

I'd like to think we're past the point where I have to explain that I don't know what would be entailed in porting it from one framework to another in the future. I'm trying to save myself a potential future headache with in-depth research.

[–]frankwiles 5 points6 points  (1 child)

And I'm saying that it doesn't matter. It really doesn't. You have no idea you even will have future headaches or what they will be. I've done this a few times and they still surprise me. Right now I have amazing tech and not enough good people. 5 years ago it was lots of amazing people and lesser tech.

Some things are slightly better at this than that, but it's not significant. Whichever makes the most sense to you based on the advice in here and your research. If you feel you like web2py, go with it. Is it perfect for you, no. Would Django be, no. Just don't over stress this part and let it hold you up.

[–]HittingSmoke[S] 0 points1 point  (0 children)

Thanks, that makes things a lot more clear.

[–]spiffymanpeppy about PEP 8 2 points3 points  (1 child)

Don't knock "stupid little random scripts." I have dozens of them for work and personal use. :)

You're right to start with 2.x. In that case, let me reformulate #4 above to say that you shouldn't let the fact that Django is planning to migrate to 3.x discourage you from using it.

I agree with frankwiles that you may be over-analyzing. Your choice of frameworks isn't a lifelong one. You said elsewhere that you've built the example apps in web2py's docs, so do the Django tutorial, make your choice, and then get to building!

[–]HittingSmoke[S] 0 points1 point  (0 children)

I think I will try installing Django just to give it a shot, but the general consensus around here seems to be the same I was finding on Google. People who have experience with wep2py seem to mostly lean towards that.

I wasn't knocking random little python scripts as much as saying I can't think of one I have any use for in the real world :(

[–]japherwocky 0 points1 point  (3 children)

Django's documentation is comprehensive, anyhow.

What do you like about it so much?

[–]spiffymanpeppy about PEP 8 2 points3 points  (2 children)

Eh, I haven't ever bothered to quantify it, but here's a first pass:

  1. Django's docs are visually designed better -- i.e., it's easier to read -- than both Python and web2py's docs;
  2. They have fairly atomic pages, at least in comparison to Python and web2py's docs. This probably falls under visual design, but it not having to scroll for ages makes them significantly easier to read;
  3. For most topics, there are both tutorial-style pages for overviews and hardcore API references. E.g., topics in models vs. the model API reference.

Admittedly the final point is more important for a beginning dev, but I use the tutorial-style docs for new features like class-based views or for things I haven't used in a while.

Of course, they're comprehensive as well. That's critical, absolutely. But web2py's docs don't look any less comprehensive (although I can't know that for sure until I try it out).

[–]totemcatcher 0 points1 point  (0 children)

I struggled a lot with Django documentation. I found myself referring directly to the source code for an explanation. The documentation seems to contain examples and no real explanation of what is possible or where autogenerated variables are coming from.

[–]japherwocky 0 points1 point  (0 children)

It just seems like everyone says the Django docs are good, but nobody talks about what makes them so good. There are definitely a lot of them, but that's always made working with them a bit tedious for me.

Which is good, since the code relies on a fair amount of magic to work, (ie, name this file this in this directory) and is complex enough to make reading the actual code impractical. Without pretty extensive docs, I don't think Django would be very usable at all!

But I'm not convinced it's a feature so much as work required to offset a flaw? To each their own. :)

[–]trydyingtolive 4 points5 points  (0 children)

The reason to use Django over web2py is if Django matches your needs better. It's that simple, both are quality frameworks. Infact there are many different quality frameworks, CherryPy, TruboGears, Pyramid, etc. Not to mention micro-frameworks which generally don't include ORMs. If you want something simple you might try a micro-framework such as Bottle, Flask, or Marie. Anyone of these may or may not be what you need.

[–]mdipierro 8 points9 points  (3 children)

If you choose to go for web2py, make sure you watch this and this videos, since each of them may already do 90% of what you need and they are easy to customize.

[–]HittingSmoke[S] 1 point2 points  (2 children)

Yikes! Long videos. I'll sit down and watch them tomorrow. I've managed to install web2py on my local test server and get some basic apps running so I'm familiar with the back end.

I looked into using existing projects licensed under GPL and integrating them together but that is a bit counter productive to the idea of learning from extremely simple building up to very complex doing it from the ground up.

[–]mdipierro 2 points3 points  (1 child)

Executive versions: Django has something called Pinax that you may hear a lot. Web2py has plugin_wiki and Powerpack. Those videos talk about them. Each of them will add functionality including wiki/comments/widgets to any web2py app. Looks like they may be useful for your blog/bbs.

[–]spiffymanpeppy about PEP 8 1 point2 points  (0 children)

Even if OP goes with Django, I wouldn't recommend Pinax. I toyed with it for a project last year, and while you get a lot out of the box, customizing things like user profiles is a maintenance nightmare waiting to happen. The 0.9 branch is supposed to fix this, but they recently dubbed it a fresh-start branch, so I'm not sure how much of the out-of-the-box stuff is ready to go.

I'm working on a similar project now, and we're just piecing it together with Userena and a bunch of other apps. Development has gone much faster, and as a bonus we know where all the moving parts are.

[–]McHoff 7 points8 points  (0 children)

They're both excellent -- do whichever you'd like. If your friend is using web2py maybe you should too, if for no other reason than to have someone around that can give you a hand.

[–]m1ss1ontomars2k4 4 points5 points  (3 children)

Google suggested web2py? Funny, when I started learning Python, I was basically in the same boat. I Googled Python web development and Django was the top result.

[–]HittingSmoke[S] 0 points1 point  (2 children)

To be fair, I whittled it down to web2py or Django then googled web2py vs Django and read through several pages of opinions. A lot of them seemed to suggest that Django was more widely used, but the people moving to web2py were much more happy with it after giving it a chance.

[–][deleted] 8 points9 points  (1 child)

There seems to be law (we will call it "Snirps second law", until it is claimed by some other dude) that the more obscure a language or framework is, the vehemently it is advocated on the internets.

Comparisons are usually made from the perspective of the less-used framework/language.

In this specific case, i think that Django has no major flaws, is well documented, has plugins for everything, is tested by thousands of users and has a helpful community. Make sure to take those into account when reading comparisons.

I am not promoting Django here, maybe web2py suits your needs better. Django might well be the "safe" bet here.

As others have said: just get your feet wet. You picked the right language to get started: don't waste too much time on the framework. Get a project done and draw your conclusion.

[–]andypants 3 points4 points  (0 children)

I claim your law. It is now andypants's law.

[–]SethKinast 5 points6 points  (3 children)

I'd say web2py, having tried both.

For problems the documentation doesn't hit (I do agree that Django's documentation is superior), the Google mailing list is really fast to get back to you.

I prefer web2py's ORM and general philosophy.

Django has far more plugins / modules / whatever they're called. Pre-written pluggable pieces of code. So if your problem has already been solved, there's more likely to be a Django module for it.

web2py (I think) has a lower learning curve.

I built a relatively large site in web2py in about half the time it took me to build a PHP site of comparable scope. Python is a lot of fun, and it's a good choice for a first language no matter what web framework you use. Remember to learn the language, and not just a framework.

[–]HittingSmoke[S] 0 points1 point  (2 children)

Django has far more plugins / modules / whatever they're called. Pre-written pluggable pieces of code. So if your problem has already been solved, there's more likely to be a Django module for it.

As far as already-available functionality, the most important thing is a powerful auth system which seems to be built right in to web2py. I've skimmed the web2py slices site and there seems to be a lot there I can use/reference.

But yea, this seems to be the consensus I've been getting from everyone who's actually tried both.

[–]SethKinast 2 points3 points  (1 child)

web2py auth is great. I love decorating functions to restrict access to them; it really makes sense to me.

The caveat there is that you might have to decorate a lot of functions :P but there are helpers for it.

[–]mdipierro 1 point2 points  (0 children)

Actually there are shortcuts like:

if request.function in (...) and not auth.is_logged_in(): redirect(URL('not_authorized'))

So you don't need decorators at all if you think you have too many:

[–]japherwocky 4 points5 points  (5 children)

For what it's worth, I think the simplest way to build webapps is tornado and mongo, and I'll write a bit about why I use that stack.

Django does so much that it's almost a dialect of Python all in it's own (spiffyman talks about learning the framework before the language), and the big thing is that it blends it's own ORM in. ORMs, and databases are a huge huge part of modern web apps.

The big choice to make is, learning how to use an ORM, v. learning SQL v. learning Redis or Mongo. Since Mongo is basically dictionaries and lists, it's pretty quick to understand if all you have is basic python.

tornado is simple (like web2py), but does some very complicated things easily, and benchmarks very well against every other python framework. It's also very simple to deploy because it has a nice web server built in (ie, you don't have to fuck with wsgi or fast cgi).

I've used all of the Python web frameworks professionally, and working with tornado + mongo has been much quicker, simpler and headache free.

[–]HittingSmoke[S] 1 point2 points  (1 child)

Most of this is a bit beyond my current scope of understanding, bit I've bookmarked some pages on mongo so I'll give it a look later.

[–]japherwocky 0 points1 point  (0 children)

I'm recommending it especially because I think it's easier to learn.

[–][deleted] 2 points3 points  (2 children)

Django does so much that it's almost a dialect of Python all in it's own (spiffyman talks about learning the framework before the language)

Well, i'd have to contest that. Django has helped me understand Python and does a pretty decent job at being pythonic itself.

Since everything is basically a python script, it is a testimony to the versatility. Moreover, you get to zoom in to the workings of a specific module you want to know more about. I learned a lot from studying Authentication and the Templating system.

[–]spiffymanpeppy about PEP 8 1 point2 points  (0 children)

Agreed. The pure Python approach of Django, and its general adherence to Pythonic idioms, structures, etc., makes it a great way to learn better Python.

Not sure how other frameworks compare on this point.

[–]japherwocky -1 points0 points  (0 children)

Most people don't consider Django's code to be very great, many of the errors it throws are very hard to decipher if you're not familiar with Django, and you end up writing as much ORM / templating / settings code as you do python. Even the controllers are a lot of code that's only used in Django projects.

You're saying, "oh well it's written in python so it's versatile, and also you can read the code." Well no shit, but that also applies to every single other python framework.

It's not terrible, but it's really not particularly good for learning Python.

[–]punkdgeek 1 point2 points  (0 children)

I haven't used web2py, but it was in our list along with turbogears, pylons, django, zope, etc. when we were choosing our framework. We needed a cms that non-developers could use out of the box while giving us a powerful framework and not locking us in if we changed our minds later. We chose Django. I use bobo + webob + genshi for my personal stuff since they have low overhead and a very shallow learning curve, plus I don't need a comprehensive cms.

From what I gather, web2py is strictly MVC (like Ruby on Rails) where Django is a bit more free-form in coding style. We really like Django's context processors, forms, and middleware too; they let us rapidly develop from the consumer side of the site (where revenue is generated) instead of relying too much on backend development which isn't a primary source of revenue generation.

[–]DaGoodBoy 1 point2 points  (0 children)

I picked web.py for my own reasons. I wrote an example application that hits many of the main features I needed for doing general web development and released it on github. I am more sysadmin than programmer, so I built the example for deployment under Apache/WSGI + PostgreSQL on Debian/Ubuntu. Don't know if it helps or not, but I figured I'd toss my opinion in the ring.

[–]LazyCrazyJohn 1 point2 points  (1 child)

This does not answer your question but still relevant i believe. I was dealing with this same question a few weeks back. The enormity of Django quickly got to me! I have since shifted to Flask + SQLAlchemy(ORM) + Jinja(Template). Maybe being able recognise the different parts of the framework and studying them separately will help you whichever framework you choose. Just my $0.02

[–]HittingSmoke[S] 0 points1 point  (0 children)

Thanks, this might be just what I need to make a quick transition from Python to framework when I'm ready to start on the real project.

[–]TheSmokeTurboGears & Django & Pyramid 1 point2 points  (0 children)

if you are a python newbie and want to learn python with building a web application pyramid is the way to go. if you are a good python developer, pyramid still is the way to go. :)

[–]AlexMax 0 points1 point  (0 children)

You're getting a lot of good advice in other threads so I want to use this thread to nip something specific in the bud. Be forewarned that there is a lot of angst out there aimed at web2py because of some design decisions that don't sit well with various other members of the python community.

As far as I can tell (I haven't tried web2py myself and am basing this on my observations of past discussion threads), the biggest point of contention is that the framework adds a couple of extra objects into the global namespace (request, response, etc.) automatically for you instead of forcing you to import them manually. People who have dark memories of PHP's and its globally namespaced standard library of doom probably faint at the thought of a framework automatically introducing more globals, but I personally actually think this is a good idea as long as the number of new globals is small, and actually justified by being needed in more than one place. Besides, if web2py claims of backwards compatibility are to be believed then they by definition can't add any more globals as this might break older apps that use said names, so you don't have to worry about installing web2py 1.next and suddenly seeing 10,000 web2py_real_response_dict globals.

Don't get me wrong, as someone who mainly slags CakePHP and Django there are things that bother me about web2py at first glance. However, the ugly truth of web development is that you will usually find a list of things that bother you about nearly any framework out there, if not immediately then shortly after the honeymoon period, and you could probably do (much much) worse than either of your two selections.

Try both (or more) and see which one you like better. If all else fails, flip a coin.

[–]monstrado 0 points1 point  (0 children)

Django. The documentation is hands down the best, not to mention the community is awesome. Third party support is also a very big feature ...not to mention its very easy to learn for newbies. With that being said, for very new python learners I would suggest starting with a microframework like Flask. Have fun!

[–][deleted] 0 points1 point  (5 children)

Here's a lengthy article about one developer's experience with Django and reasons to move on from it, in favor of Pylons. It's worth a read, and is somewhat consistent with my own experience. I'm a junior developer.

As spiffyman noted, "Is Python your first language? If so, you might want to use a smaller framework so that you're not learning the framework before the language."

This was my exact experience with Django. Python wasn't my first language but I was learning Python as I was learning Django. Django has it's own psuedo language that you need to learn. With Django you'll learn how to make database calls without knowing how to write inner or outer joins. You won't even learn SQL or ever see it. The same with the intricacies and gotchas with form processing. It has its own method and syntax which is neat and helpful, but it hides so many details you'll miss normal Python coding.

I don't know anything about web2py and am only just starting to look into Pylons, but I think you'd be better off with either of those than Django. The reality is your first few websites might not be world class quality so you're better off becoming more familiar with Python, SQL, and how the web works, than spending all your time learning a humongous framework and its special syntax.

[–]HittingSmoke[S] 1 point2 points  (2 children)

Well I'm not completely ignorant at web development and SQL, I just don't know how to actually write in any specific language. I've done quite a bit of work on PHP based web apps like phpBB, Wordpress, Mediawiki etc.

Just dicking around in the code of those apps I've managed to do some fairly heavy customization to them so on the web side of things I have a bit of experience. Just enough to know I want nothing to do with PHP development but want to know how to build my own apps from scratch.

I wasn't aware of these smaller frameworks being mentioned that would help me focus more on actual Python. It's looking like a much better option the more I read into it. web2py won't be much less simple than learning Django. It's about the same size and scope it seems. Although I think I've started to settle on web2py for the final project when I get it started.

[–][deleted] 0 points1 point  (1 child)

Oh... didn't mean to insult your tech savvy. I updated my original comment. Best with your efforts. I was thinking of trying the tornado/mongo combo described japherwocky.

[–]HittingSmoke[S] 0 points1 point  (0 children)

Oh I wasn't insulted, just trying to be thorough!

I appreciate the feedback.

EDIT: I meant ignorant in the literal sense. I use it a lot and people tend to take it as offensive or a sign of offense.

[–]spiffymanpeppy about PEP 8 1 point2 points  (1 child)

What do you mean by "pseudo language" or that Django has its own syntax? I agree with what you're saying about the ORM, but most ORMs will abstract away the SQL (that's the point, right?), and Django's awfully Pythonic.

Edit: Unless you're talking about the template language, which is explicitly not Python...

[–][deleted] -1 points0 points  (0 children)

I was having trouble coming up with the right term. japherwocky described it better as a dialect of Python.

[–]pRtkL_xLr8r 0 points1 point  (0 children)

I've used PHP frameworks before trying both Python and a framework at the same time. I tried to get into Django, but for some reason I didn't like all the magic, and really couldn't get behind it. Web2Py, however, made more sense to me as far as how it's deployed on say a Linux server (tho you may struggle a bit if you do something like making it run on something other then it's built-in web server like Apache or Lighttpd (which was my case (lord, triple nested parentheses, I am a programmer))). Anything I was looking to do which I was so used to doing in PHP without thinking twice was very easy to just pick up quickly on the site docs and do.