top | item 7030994

Must-have Django packages

154 points| rule30 | 12 years ago |devcharm.com | reply

96 comments

order
[+] falcolas|12 years ago|reply
Interesting, my fairly large django project uses none of those. Instead, the addons we consider to be critical are these these:

    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.

[+] belluchan|12 years ago|reply
Does django-redis block? I'm not sure I'd make a connection from django to anything other than a low latency queue.
[+] oinksoft|12 years ago|reply
pytz probably doesn't belong in a discussion of Django libraries. It's needed by pretty much any Python program that works with localized datetimes.

  > jinja2 for doing templates outside of returning data
What do you mean?
[+] sdfjkl|12 years ago|reply
Amusingly, my must-have Django packages are mostly things that replace large chunks of Django (Jinja2 for templates, a DB connector/ORM for whatever database the project needs, which even for PostgreSQL is often plain SQLAlchemy).

I guess I'll just use flask.py or something for my next project. This is not meant as criticism, just my personal experience.

[+] mixmastamyk|12 years ago|reply
Yep, having everything built-in is a double-edge sword.

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.

[+] belluchan|12 years ago|reply
Django guardian's performance is ridiculously bad. Better roll your own. We're using it and stuck with it at this point, but some of our page loads have thousands of queries because of all the permission lookups. Permissions probably need to be cached in memory.
[+] michaelmior|12 years ago|reply
"Must-have" anything always feels like clickbait to me.
[+] polpetta|12 years ago|reply
Eh, Internet is based on clickbaits and lolcats. $ad but true.
[+] cheshire137|12 years ago|reply
Just reminds me of scummy in-your-face ads everywhere, like at a mall or in a women's magazine.
[+] aikii|12 years ago|reply
Cripsy forms, because simple things like adding the necessary markup for bootstrap to forms is super-boring otherwise ; in general, it helps with custom form layout, which is usually a template maintenance hell

https://github.com/maraujop/django-crispy-forms

[+] dkoch|12 years ago|reply
I've found django-allauth a bit friendlier than django-social-auth, and it covers registration of local accounts in one package.
[+] bmelton|12 years ago|reply
Oddly enough, django-social-auth has been deprecated for some time now in favor of python-social-auth[1] (same author). It is more user friendly than django-social-auth, and also offers up a lot more functionality that django-social-auth wasn't giving me.

[1] - https://github.com/omab/python-social-auth

[+] mixmastamyk|12 years ago|reply
Everyone recommends the django-toolbar for spotting slowdowns in your SQL... ok, installed it. I almost never see any tips on how to actually do that though. What now?

(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.)

[+] vangale|12 years ago|reply
I would say there are two primary ways DDT helps you spot database performance problems.

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.

[+] true_religion|12 years ago|reply
If you're doing a lot of # crunching, you might try using Cython for those bits. You can get a 10x speedup without changing semantics and just annotating types.
[+] reinhardt|12 years ago|reply
I've been away from the Django ecosystem for the last few years.. how is Pinax doing these days?
[+] mixmastamyk|12 years ago|reply
Seems dead, a shame because I wouldn't mind a more complete starting point when creating a project.
[+] TheMakeA|12 years ago|reply
What are people using these days for compiling their static assets (js minification + concatenation, etc)? We have been using django-pipeline but it has been a nightmare.
[+] conesus|12 years ago|reply
I use Jammit for static asset compression.

(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.

[+] peter_l_downs|12 years ago|reply
We're currently using Django Compressor [0], and it works pretty well. It was slightly annoying to get it to work well with staticfiles [1], as we host all of our content on S3 and serve through cloudfront in production. But, it's nice because now we can do this in our template:

    <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...

[+] Spiritus|12 years ago|reply
Why has it been a nightmare? I find it pretty neat. Was using django-compressor earlier but it didn't have support for Python 3.
[+] falcolas|12 years ago|reply
Caveat: Small site, low enough traffic that a few kilobytes per request won't break us.

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.

[+] papercruncher|12 years ago|reply
We switched to the google pagespeed module for nginx and stop worrying about it. It doesn't do minification very well but it does concatenation and takes care of a bunch of other stuff as well, like image resizing, CSS concatenation etc.

We used to use the HTML5 Boilerplate script but it was horrendously slow on EC2

[+] mikewhy|12 years ago|reply
http://brunch.io/ I've use it in Django, Flask, Rails and static sites with Chaplin, Backbone and now Angular. Works a charm.
[+] tdj|12 years ago|reply
I'm pretty happy with django-compressor.
[+] rule30|12 years ago|reply
This is a brilliant question, any package about that?
[+] msonawane|12 years ago|reply
nginx + pagespeed should be better way of doing it
[+] porter|12 years ago|reply
What about South?
[+] gmu3|12 years ago|reply
I agree South should probably make the list although database migrations have finally made their way into the Django core so perhaps that's why the author didn't mention South.
[+] rule30|12 years ago|reply
Have a go at editing the `Utils` section.
[+] glynjackson|12 years ago|reply
A few I work with on most projects are...

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.

[+] timc3|12 years ago|reply
I would recommend DjangoRestFramework any day over Tastypie after having used Tastypie for two years.

DjangoRestFramework code base is better, it's better thought out, it should be part of Django core.

[+] collyw|12 years ago|reply
I currently use Tasypie.

Would I gain anything switching to Django REST framework?

[+] edanm|12 years ago|reply
We switched form Tastypie over to Django REST Framework, and are overall pretty happy. Cleaner, clearer code that's easier to work with.

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.

[+] SEJeff|12 years ago|reply
Bonus points that Daniel Lindsay (tastypie author) got a job with Amazon, works on boto, and does very little with tastypie anymore. D-R-F is actively maintained and is a bit nicer to work with. Also, the autogenerated apiview "self documenting api" is super duper nice.
[+] natmaster|12 years ago|reply
The APIs are more sane. Added bonus of a cool HTML api explorer view.
[+] qoo|12 years ago|reply

[deleted]

[+] waterlion|12 years ago|reply
"Django REST framework is an insane framework"

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.)

[+] IgorPartola|12 years ago|reply
Bah. Your comment is probably one of the less informative ones here, so I downvoted you. Look, there are turns of phrase that shouldn't be used by responsible members of certain communities in public. Saying something like "watch out, woman driver" is pretty offensive universally. We can all benefit from a more inclusive and positive language.

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>

[+] epochwolf|12 years ago|reply
How is this heteronormative? I didn't see any reference to gender in the entire article.

Also, you're really stretching the "discrimination to the mentally ill" thing to the point of silliness.

[+] maxerickson|12 years ago|reply
At a minimum you chose an odd target for your satire. There isn't really any adjective that can be used in that location that will add much information to the text (it is just expressing enthusiasm).

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.