427 points · by Lightning · 13y ago · 170 comments
Django is still a cornerstone of our startup and we're way past the point where folks have traditionally said "Django starts to constraint you". We've found that to be untrue. We love the templating, the ORM and all the built-in tools (not to mention 100s of libraries that get you an 80% finished feature in 5% of the time).
I hope to meet a lot of you at Pycon, I'd be happy to buy you a beer. I'll be wearing the bright orange Zapier shirt, you can't miss me. :-)
Not to hate on Django, jacobian, or the LJ-World, I appreciate the effort put into the system. But I don't think it really has much to offer in present-day for people developing new, serious platforms. I feel the same way about most other "full-fledged" MVC frameworks, because they all seem to far exceed what ought to be the logical bounds of their influence. In many cases you feel like you're writing Django, Cake, or Rails and not writing the actual language based on, because these frameworks mandate so much and require special integration to do much of anything. In something like Pyramid, you write Python, and Pyramid provides the pieces that make it easy to bundle together and publish as a website.
I've had positive experiences with Sinatra, too. "Microframeworks" and close cousins like Pyramid are really much more appropriate dev platforms, imo: modular, unpretentious, exist simply to help you get your program onto the web in a fast, concise, and simple way, without attempting to inject a rewrite of the standard lib or force you to conform to their unique flavor of MVC, their crappy ORM, etc.
I've never had an issue with Django being inflexible. The strong conventions and the fact I don't have to make a decision about every little thing makes me, and the ecosystem, more productive.
I don't really understand this. Other frameworks don't require you to "make a decision about every little thing" either. It's not like they're just a blank file that says "<WRITE FRAMEWORK CODE HERE>". They come with defaults, things that are in place automatically. They come with suggestions and recommendations for optional stuff. They come with docs and tutorials. They just don't make illegitimate mandates, they don't revolve around a specific ORM or a specific template.
If you start a clean Pyramid project with the "alchemy" scaffold (recommended) right now, you'll have Chameleon, SQLAlchemy, and URL routing automatically chosen for you. You don't have to make any more decisions. You just have to open up views.py and start coding.
> perhaps your people just don't have much exposure > new, serious platforms
Both could have been omitted and your points would still have been valid.
Anyways, I'm not advocating Django as "the one true way", just stating that is hasn't hindered us in the least. :shrugs:
Also strange to hear that Django has a unique style of MVC, it seems pretty standard to me (and from what I see a lot of new frameworks are aping it).
What Django does well is provide a pre-built and (IMHO) easy to use set of default tools. This does not mean that you must use these tools, they are just there by default if you need them. You could really just use Django as an HTTP routing tool.
While I'm sure you're right that it's not a hard requirement in that you can figure out how to make it work, it's not an easy thing, and you'll be fighting the framework and the conventions all along the way as interdependent stuff stops working. Again, in my experience. If things have improved significantly, I'd like to know.
When toys ship "batteries included", it's easy to pull them out and replace with a different brand, if you want. Django, and most other web frameworks, don't make that interoperability a serious concern, afaik. When you use a framework, you are essentially adopting its code into your project all at once, and you become responsible to make sure it works and adapts to your needs even if upstream dies out or makes a decision that renders new versions unusable for your use case. "Non-removable batteries" are therefore a major design flaw in your project, even if you haven't had occasion for it to be exposed yet. The batteries of monolithic, "opinionated" web frameworks like Rails and Django may be partially removable, and maybe they've improved recently, but newer frameworks like Flask and Pyramid don't have this issue at all, and it makes them much more flexible.
A few specific things I like about Django:
1. A decent app ecosystem
2. Lots of documentation and a fairly mature codebase.
3. Django south for migrations.
1. What is "a decent app ecosystem"? We call these "libraries" elsewhere.
2. Pyramid same. (and, as someone whose attempted to build apps with both, I find Pyramid's much clearer)
3. This is ORM specific, not framework specific. SQLAlchemy has sqlalchemy-migrate or Alembic.
This is far less adaptable than Pyramid, which makes most internal functionality like that accessible via the request object, which can be accessed by your template language's typical variable evaluation syntax, and which can use Mako or the default Chameleon with just a one-line configuration change, or Jinja2 and others by installing a simple shim layer that is mostly boilerplate.
Personally, I've tried to use mako with django and found it unwieldy to pass the correct information across the controller-template barrier. This was some time in the past, however, so perhaps either the adapter or documentation has improved and the problem no longer exists. The real issue, however, is that a generic web framework would make it difficult to replace unrelated user-facing libraries in the first place.
Jingo serves purely as a minimalistic bridge between Django and Jinja2. Coffin attempts to reduce the differences between Jinja2 templates and Django's native templates.
I remember, at one point, that I felt Django templates were limiting me, and started swapping them out piecemeal for Jinja, and my designers started to absolutely hate me. Not because they had to convert anything, I converted everything by hand, but just that the amount of syntax you can cram in there keeps everything less pure.
Since then, I realized I was trying to do too much in the template and started putting things where they belonged, and now, whenever I work with Jinja or Mako, it feels a little too much like editing Wordpress themes or something in PHP.
Long story short, I learned the hard way that if you're putting logic in the templates, you're probably doing something wrong, and I agree that it is not only a reasonable design, but a very good suggestion as well.
Define awful in concrete terms.
I've not been much constrained by Django in any way.
Even if all of those are "better" in some spec-listing way, Django could still be better by offering better integration for it's tools.
Like the iPhone, in actual use, beats phones that are better than it "spec-wise".
You can use Django with Jinja2 and SQLAlchemy.
There are problems Django solves and problems Pyramid solves and there I nothing wrong in using one or the other.
That's why I use Django.
Having used and rejected each of the things you mentioned for various reasons, I think you're making the common mistake of assuming that other people have the same challenges and preferences you do.
It's particularly pointless to do this in a project release announcement thread – if it really doesn't work for you, just skip over it rather than flaming.
i think you're wrong about the ORM. django's ORM is actually really good, its just that the api is optimized for different use cases than SQLAlchemy. django ORM does a better job of simplifying the most common queries. its worse at complex queries. thats a reasonable trade off and i think you go way too far when you say its "awful".
Well, that means you are not past that point. First you learn to love your tools, then you learn to hate them, and it's ok.
It's not really that hard to reach the point where the orm pisses you off (examples: https://speakerdeck.com/alex/why-i-hate-the-django-orm by core dev, there is a talk somewhere on pyvideo.org), especially if you have actually written some complex sql queries in your life.
I'm not saying the critique is bad, it's just that in practice it's not something you'll be noticing day to day, and if you are, switching to pure SQL or SQLAlchemy is not a bad alternative (and Django makes that very easy to do).
I've been working on a small side project the past week or so using the 1.5 RC and following along the best practices recommended by 2 Scoops of Django -- https://django.2scoops.org
If you haven't already, I highly, highly recommend picking up the 2 Scoops book. It's got some great, proscriptive advice and is an easy-to-follow roadmap that helps answer a lot of "what is the right way to do this?" kinds of questions. Setting up your settings files for multiple environments, using CBV's, understanding the new User Model features, writing tests, recommended 3rd party tools, securing your setup -- these things are all a lot more clear to me.
And it's actually really well written, not just a bunch of recipes. Their explanation of mixins, for instance, is one of the clearest, most concise I've ever come across. Well worth $12 and a few hours of time to read through it.
If anyone knows of any other good first-up books / websites (are there any interactive tutorials Treehouse / Codecademy style?), please let me know.
The official Django Tutorial is still a great starting place for getting your head wrapped around that stuff -- https://docs.djangoproject.com/en/dev/intro/tutorial01/
I'm also going to check out http://gettingstartedwithdjango.com
That sentence is of course followed by caveats about Python 3 support being experimental at this stage, but all-in-all I think this is a sign that we are finally at the tipping point for Python 3 to start gaining mainstream usage.
Thank you Django community for moving the ball forward for everyone.
Technically, however, it's pretty rock-solid. I'll be launching a site built on Py3/1.5 is about two weeks, and aside from constantly forgetting to `print(...)` instead of `print ...` it's been surprisingly smooth sailing.
It would sure be great to have a list of django sub-projects and their Python3 status.
Regardless, even if we start with Python2.7 and bump up to 3.3 in a few months, this is a great step!
* South doesn't have Py3 support in core, but there's a fork that does and seems to work perfectly: https://bitbucket.org/aaugustin/south-python3
* lxml as of v3 seems to have py3 support (I haven't tried it, but looks like it does).
* simplejson is now in the standard library as "json", so yes there.
* requests works, since v0.10 (about a year ago).
* django-compressor is not ported; however, django-pipeline does run on Python 3 and is basically -compressor's successor. It works great.
* gunicorn works on py3 (as does uwsgi and mod_wsgi, btw.)
* jinja2 hasn't been ported yet.
* twisted is actively being ported right now, and has gotten to the point of "kinda working". You can follow along at http://twistedmatrix.com/trac/milestone/Python-3.x and http://twistedmatrix.com/trac/wiki/Plan/Python3.
* txAMQP probably can't get ported until twisted does.
* django-rest-framework has Python 3 support, I think it's fairly recent, but it works well.
This list is about typical of what I've found doing Django/Py3 work: many things are ported, a bunch more have good alternatives, and a few things are still missing.
The reasons to upgrade to Python 3 are both numerous and serious. If the only hit on your code base is to change "print this" to "print(this)", by all means upgrade. And most conversions are automated -- just run a script named "2to3":
http://docs.python.org/2/library/2to3.html
Asking why one would want to move from Python 2 to Python 3 is like asking how much a boat costs -- if you have to ask, you can't afford the consequences. Here are some of the reasons:
http://wiki.python.org/moin/Python2orPython3
A quote: "At the time of writing (July 4, 2010), the final 2.7 release is out, with a statement of extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is under active development and has already seen stable releases, such as the recent 3.2. This means that all recent standard library improvements, for example, are only available in Python 3.x."
A more complete list of the changes:
http://docs.python.org/3/whatsnew/3.0.html
Bottom line -- if you don't migrate to Python 3, over time the corner you're painting yourself into will become smaller and smaller.
I guess having it be a special User model is just part of the deal with Django's good out-of-the-box admin. I don't even remember how the various Rails plugins (ActiveAdmin, for example) generates the scaffolding needed for an authenticated user.
It's very easy to extend the existing user model rather than creating one from scratch. I had to do some unconventional auth stuff recently and I only extended auth.User slightly (and also wrote a slightly modified authentication backend).
It's good that they're providing it, but I think the complexity is going to turn people off (I know I won't be using it unless it's simplified at some point in the future). User profiles have always been used for adding data to User models indirectly, and I think this is probably going to remain the best way to handle it for most uses.
https://docs.djangoproject.com/en/1.5/topics/auth/customizin...
It appears the database migration is the biggest hurdle, but I don't think there's a way around that. User profiles require a join and that can be suboptimal, which is why this is a useful addition. If you weren't running into problems before it's probably better to not change (though that's usually the case for working code).
[I'm a Django committer, FWIW.]
What "jaw-dropping nastinesses" are those, and why didn't you check and report them during the beta/rc phase since you were "hoping it would be awesome"?
Besides avoiding a join in the DB (or worse, a separate select), being able to override user model methods has been an incredible benefit to my projects.
Maybe this would be a nice way to contribute to Django...
> rails generate active_admin:resource [MyModelName]
I haven't used ActiveAdmin in a few months, but when I last did I was really impressed.
https://docs.djangoproject.com/en/dev/ref/templates/builtins...
[1]: https://docs.djangoproject.com/en/1.5/intro/tutorial05/
[2]: https://docs.djangoproject.com/en/1.5/intro/reusable-apps/
IMO, the perfect setup for most non-Facebook sized money-making web apps is nearly always dedicated SSD-powered database hardware connected to a cheap cloud of virtual boxes to serve requests. Spending engineering $$$ on scaling your data across unreliable virtual instances often is not a good idea.
Going all-dedicated, if you can afford it, is great for pretty good uptime at zero engineering cost. I recommend SoftLayer for this: they sell cheap and reliable dedicated servers connected to pretty good networks (just stay away from their older Dallas-based DCs, but DC5 is good).
Reasons:
Local development with Appengine is pretty bad. Good luck debugging and profiling production issues.
Appengine will make you jump through many hoops that undermine or completely drop pieces of the Django framework.
Getting data out of Appengine is a huge nightmare and timesink.
If you ever decide to migrate off Appengine you will need to rewrite almost everything.
I still have an app on GAE (the high availability version) mostly because I don't want to roll out my own HA Mongo DB. At some point it will become cost effective to do my own.
The other AWS plus: when my response time skyrockets, I can figure it out and fix it.
I recently made the switch from Datastore/djangoappengine to Cloud SQL, and it has been a far better experience.
(where I work)
I'm happy to elaborate, but I would stay as far away as possible from GAE. Our experience was terrible. I should note as a disclaimer that we did not use the high availability version.
Docs on running native django on cloud sql: https://developers.google.com/appengine/docs/python/cloud-sq...
A guide I used to set it up: http://www.joemartaganna.com/web-development/running-django-...
Last time I touched any of these sites other than to add security patches and the likes was 6 months ago, so it could be better/worse these days, YMMV.
I really, really wanted to say to you Python 3, because:
- It is better (it fixes some annoyances)
- Django is working really great with it
But some things (that Django uses, but are not Django) are not working yet. Things like MySQL adaptors, South, etc
Or maybe go with Python 3 and wait for the issues to be fixed, they probably will, soon enough
There are ways to write software that's compatible with both Python 2 and 3 (using six for example: http://pythonhosted.org/six/)
But I guess it's mostly developers not having the time to update (it's easier if you kept it updated and not using some old constructs)
ETA: That said, the advice to stick to Py2 right now is probably good. There's still some key missing 3rd party packages, so you'll generally be happier as a Py2 user right now.
I'm really looking forward to migrating a few projects up to Python 3 and Django 1.5. It's going to be awesome!
but... a lot of packages are not ready for 3 yet. So it depends how far you want to go.. Playing around by yourself? I'd go with Python 3... if you need to leverage a lot of the packages you'll need to drop down to 2.7
Plus, 2 is not going away in near future, and you'll be able to pick up 3 easily after that
What framework do other people using NoSQL data stores use?
We've been big fans of storing core data in Django models, but using things like key/value stores to store random extra bits that aren't exactly core to the model. Redis is great for this, or another model as triple store style GenericRelation if you need to query on it.
I don't imagine the nonrel branch will move again, its such a departure from core Django. Look into using Flask, as there aren't many "mature" frameworks that do NoSQL core.
The real loser is Django Reindhardt, who Adrian Holovaty named the framework after, and is now bumped off the first page of Google results.
I am getting turned off left right and centre by frameworks - Django and even Flask just make reasoning about the request/response more difficult.
Maybe I don't know how to use this but ... It would take me three months to read the new Django docs.
I am not a hater here, just wanting the simple life
However, I understand what you mean about request / response, I don't like how this is handled in most python frameworks actually, it's usually too much abstracted away.
The nicest (imperative) environment for asynchronous execution I've seen is Objective C/Cocoa for some reason. It has a way of showing you all the handles you might need, but it also makes it fairly obvious when and how these handles are called. Together with lambda support ('blocks') it's simple but effective.
I think the main difference is enterprise + closed source + well documented environments vs. opensource + not so well documented environments often originating from someone's hobby. When it comes to big middleware frameworks I prefer the first, but small lean stuff such as Flask is just fine to use IMO.
My advice is to not rely too much on the docs when you want to really know something - take a look at the source, it's all there.
The port was requested by someone looking to build an RSS feed reader or checker in Sublime Text 3, which using Python 3.3. Things are moving forward.
* If you use decimal module, you will benefit from the serious speed improvements (http://docs.python.org/dev/whatsnew/3.3#decimal).
* The memory usage of strings is slightly lower (http://docs.python.org/3/whatsnew/3.3#performance-and-resour...).
#django on FreeNode is pretty good, though.