10 Django apps you're not using but should be

Flávio Juvenal
June 4, 2015
<p>There are some open-source Django apps that make our lives as Django developers easier, but sometimes we don't even know they exist! Good third-party apps can give you new features at little expense, make your tests easier or even improve the performance of your deployment process. Please take a look at the following list of <strong>10 Django apps you're not using but should be</strong>:</p><h2 id="1-collectfast">1. <a href="https://github.com/antonagestam/collectfast">collectfast</a></h2><p>Django <code>collectstatic</code> command can be really slow if you're using <strong>S3</strong>. <a href="https://github.com/antonagestam/collectfast">collectfast</a> solves this issue by comparing the md5 sum of S3 files and ignoring <code>modified_time</code>. The results of the hash lookups are cached locally using the project's default Django cache. This makes deployment much faster.</p><h2 id="2-django-bower">2. <a href="https://github.com/nvbn/django-bower">django-bower</a></h2><p>Stop bloating your Django project with frontend dependencies like <strong>jQuery</strong> or <strong>Bootstrap</strong>. This problem has been solved by <a href="http://bower.io/">Bower</a>, which is like <strong>pip</strong> for the web. But instead of installing Bower and adding <code>bower_components/</code> to your project (which will bloat your project anyway), it's better to use <a href="https://github.com/nvbn/django-bower">django-bower</a> and add <code>/components/</code> (which has <code>bower_components/</code> inside) to <code>.gitignore</code>. If you want to deploy a project with django-bower to Heroku, please refer to <a href="http://www.vinta.com.br/blog/2015/how-to-configure-sass-and-bower-with-django-compressor.md.html">this two-part post of this blog</a>.</p><h2 id="3-model_mommy">3. <a href="https://github.com/vandersonmota/model_mommy">model_mommy</a></h2><p>Easily create test fixtures with <a href="https://github.com/vandersonmota/model_mommy">model_mommy</a>. It's specially made for Django and it can recursively create models to fill ForeignKeys and M2M relationships, thus reducing the amount of code required to setup test cases.</p><h2 id="4-django-extra-views-and-5-django-formset-js">4. <a href="https://github.com/AndrewIngram/django-extra-views/">django-extra-views</a> and 5. <a href="https://bitbucket.org/tim_heap/django-formset-js">django-formset-js</a></h2><p><a href="https://docs.djangoproject.com/en/dev/topics/forms/formsets/">Django formsets</a> is a great tool for building complex forms with hierarchical relationships. But with default Django tools it's very verbose to use them, since they don't have the corresponding class based views as regular forms. Also, additional JavaScript is necessary for dynamically adding them in the frontend. Fortunately, this problem is solved by two Django libs: <a href="https://github.com/AndrewIngram/django-extra-views/">django-extra-views</a> has class based views for easily adding formsets and <a href="https://bitbucket.org/tim_heap/django-formset-js">django-formset-js</a> has a nice JS library for rendering formsets in templates.</p><h2 id="6-django-widget-tweaks">6. <a href="https://github.com/kmike/django-widget-tweaks">django-widget-tweaks</a></h2><p>Rendering Django forms according to what your designer wants is very awkward with default template tags. <a href="http://django-crispy-forms.readthedocs.org/en/latest/layouts.html">django-crispy-forms</a> solves this with layouts, which are Python files that specifies CSS classes, ids and other attributes for the fields, but at Vinta <strong>we don't agree</strong> with that approach since it puts frontend specific information on <strong>*.py</strong> files. The best thing is to keep all presentation formatting in <strong>*.html</strong> (templates) and <strong>*.css</strong> files. <a href="https://github.com/kmike/django-widget-tweaks">django-widget-tweaks</a> makes this possible by letting you specify CSS classes and additional attributes while rendering form fields in templates with a simple syntax: <code>{% render_field form.title class+="css_class_1 css_class_2" %}</code>.</p><h2 id="7-django-passwords">7. <a href="https://github.com/dstufft/django-passwords/">django-passwords</a></h2><p>Validating passwords to force the user to use a strong password is a solved problem. Don't reimplement this in your code, just use <a href="https://github.com/dstufft/django-passwords/">django-passwords</a> and you can reject passwords below a certain length, present in a dictionary or in a common sequence list.</p><h2 id="8-django-role-permissions">8. <a href="https://github.com/vintasoftware/django-role-permissions">django-role-permissions</a></h2><p>Shameless plug here 😀. This app was made by us, Vinta Software Studio, for making it easier to implement role based permissions in a Django project. For example, you may want that only users of a certain role (like manager) should be able to see some views. With <a href="https://github.com/vintasoftware/django-role-permissions">django-role-permissions</a> this is easily done with a view mixin or a decorator. It's built on top of <code>django.contrib.auth</code> <code>Group</code> and <code>Permission</code> models, so it doesn't add any other models to your project.</p><h2 id="9-django-manager-utils">9. <a href="https://github.com/ambitioninc/django-manager-utils">django-manager-utils</a></h2><p>Sometimes you need to get a model or <code>None</code>. <a href="https://github.com/ambitioninc/django-manager-utils">django-manager-utils</a> provides you a custom <code>Manager</code> for that. Other additional useful methods are available too.</p><h2 id="10-django-js">10. <a href="https://github.com/noirbizarre/django.js/">django.js</a></h2><p>Ever needed to get a URL from a url name in JavaScript, like <code>from django.core.urlresolvers import reverse</code> does in Python? This can be done with <a href="https://github.com/noirbizarre/django.js/">django.js</a>. It also makes it easy to access basic current user info, CSRF token and other stuff.</p><p>Do you feel this list is missing an essential but unknown Django app? Feel free to write about it on the Comments section below. Thanks!</p>