154 points · by rule30 · 12y ago · 96 comments
django-debreach
django-redis
jinja2
pytz
Redis for queues and caching, debreach to secure the CSRF tokens and vary your content length to avoid the BREACH vulnerability. jinja2 for doing templates outside of returning data, and pytz so you can use timezones in your data models.I also recommend installing `flup` and running via fastcgi, but that's open to interpretation.
See https://github.com/samuelclay/NewsBlur/blob/master/settings.... for my redis configuration. I also use django-redis for caching (which is higher up in that file).
It does use native python sockets, so gevent.monkeypatch would probably work.
Blocking is one of the reasons I use flup and fastcgi - it doesn't matter if one thread of execution blocks; it won't affect any other requests. I've tested this under load with some really gnarly queries, and it works fantastically.
> jinja2 for doing templates outside of returning data
What do you mean?It's handier and more straight-forward than using Django's templating engine.
I guess I'll just use flask.py or something for my next project. This is not meant as criticism, just my personal experience.
I myself love Django, though I find some parts of it a bit over-engineered (in the Java style). That is changing for the better in recent releases though. I'm thinking the render_to_response stuff and management commands, etc.
https://docs.djangoproject.com/en/dev/topics/migrations/
Andrew has significantly rethought migrations and applied the lessons he's learned from years of maintaining and developing South.
He's kept a developer diary that has been pretty fascinating to read (YMMV):
http://www.aeracode.org/2013/11/27/new-apps-migrations/
and others at:
http://www.aeracode.org/category/django-diaries/
[update: route3 is faster than me, but still it's worth checking out the developer diaries]
Migrations[0] are being included in Django 1.7 which is currently under development. For those unaware, Andrew Godwin, the author of South, ran a successful Kickstarter campaign[1] the fund this effort to incorporate migrations in Django core.
[0] https://docs.djangoproject.com/en/dev/topics/migrations/
[1] http://www.kickstarter.com/projects/andrewgodwin/schema-migr...
(I suppose the SQL part of my app is not the problem though, rather the number crunching that happens on the data returned. I do lots of caching on the results instead to make the site seem responsive.)
The first is that "oh my god" moment when you see via DDT that your view is doing 100+ queries to the database. This leads to research into Django ORM features like "select_related" and other ways to cut down the number of queries.
The second is clicking DDT's handy EXPLAIN button on a single query that is taking a long time. Sometimes this can help improve performance by adding an index to a field.
(from https://medium.com/cs-math/f29f6080c131) Jammit came out of DocumentCloud, and even though it was built for Ruby on Rails you can do something like this and use it for Django pretty easily. One of the things I like about it is you can setup different named configurations for javascript and css for different sections of your site (dashboard, non-authenticated, standard). It supports lots of other stuff too.
This is how I use Jammit on NewsBlur: https://github.com/samuelclay/NewsBlur/blob/master/utils/jam.... I then compress the assets, upload to S3, and then deploy to my servers. See https://github.com/samuelclay/NewsBlur/blob/master/fabfile.p.... Each app server then downloads from S3. So I can package 2MB of static assets and deploy to to a hundred servers in 10 seconds.
<script src="{% static js/mylib.js %}"></script>
and with compress like this: {% compress js %}
<script src="{% static js/mylib.js %}"></script>
{% endcompress %}
so that referencing static files is consistent.[0]: https://github.com/jezdez/django_compressor
[1]: https://docs.djangoproject.com/en/dev/ref/contrib/staticfile...
I just enable gzipping and don't worry about minification of my own assets. Sure, it means larger initial downloads (since they're cached), but it's typically in the single digit kilobytes, and simplifies debugging like nothing else.
We used to use the HTML5 Boilerplate script but it was horrendously slow on EC2
Backend: one of the most popular API Frameworks is Tastypie. Authentication and authorization: Django Userena. Debugging: Django Extensions. Django CMS Django Haystack
These are a must for your tool kit.
DjangoRestFramework code base is better, it's better thought out, it should be part of Django core.
Would I gain anything switching to Django REST framework?
Plus, it generates a browsable api that you can explore via the web, without any extra work. Which makes life a lot easier, believe me.
I'm fed up with this kind of oppressive language. This is heteronormative and is discriminatory to the mentally ill. It's stuff like this that leads to the imbalance and under-representation in the industry. Let's boycott this author.
(I would love not to have to write "</satire>" but having seen some of the comments here, I think I need to. I wonder how many white-knights-for-women use language like this without thinking. We need some flexibility in the way people are allowed to express themselves.)
However, the original quote of "Django REST framework is an insane framework" sound innocuous enough to me. The problem I have with it is not that it's discriminatory towards the mentally ill. It's that it makes the author sound like a 13 year old kid. They could improve the sentence by using words like fantastic, great, indispensable, useful, etc. Saying that a "framework" is an "insane framework" is really kind of stupid IMHO. The author could have just excluded that meaningless sentence and the article would have been improved as a result.
Edit: also, searching through the comments on this page, you are the only one bringing up the "insane" word and making (bad) puns around it. Your original comment sounds like a reply to something someone did, except nobody here did anything like what you are accusing them of. Perhaps you might want to take to Twitter or Reddit for pointless venting at nobody in particular. </satire>
Also, you're really stretching the "discrimination to the mentally ill" thing to the point of silliness.
It wasn't a joke as such, at least its intention wasn't primarily humour. Just highlighting the fact that nearly everything everyone says is offensive or exclusionary to someone and that if we adopt the universal application of the principles of extreme gender-neutral language that we've seen advocated on HN and elsewhere, equally for every issue, we end up with lobotomised language†.
I think the use of 'insane' is fine. And I think the use of gendered pronouns is fine. But I am neither insane nor of a gender that is under-represented in the pronoun
† oh never mind
An experiment: Next time you reach for some euphemism for mental illness, consider a couple of alternative phrasings (that do not use the euphemism). Decide if the alternatives are clearer or more precise. I don't run around taking issue with word choices, but if I run that experiment, I usually choose one of the alternative phrasings.