Blog

Ideas and insights from our team

10 Django apps you're not using but should be


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 10 Django apps you're not using but should be:

1. collectfast

Django collectstatic command can be really slow if you're using S3. collectfast solves this issue by comparing the md5 sum of S3 files and ignoring modified_time. The results of the hash lookups are cached locally using the project's default Django cache. This makes deployment much faster.

2. django-bower

Stop bloating your Django project with frontend dependencies like jQuery or Bootstrap. This problem has been solved by Bower, which is like pip for the web. But instead of installing Bower and adding bower_components/ to your project (which will bloat your project anyway), it's better to use django-bower and add /components/ (which has bower_components/ inside) to .gitignore. If you want to deploy a project with django-bower to Heroku, please refer to this two-part post of this blog.

3. model_mommy

Easily create test fixtures with model_mommy. 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.

4. django-extra-views and 5. django-formset-js

Django formsets 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: django-extra-views has class based views for easily adding formsets and django-formset-js has a nice JS library for rendering formsets in templates.

6. django-widget-tweaks

Rendering Django forms according to what your designer wants is very awkward with default template tags. django-crispy-forms solves this with layouts, which are Python files that specifies CSS classes, ids and other attributes for the fields, but at Vinta we don't agree with that approach since it puts frontend specific information on *.py files. The best thing is to keep all presentation formatting in *.html (templates) and *.css files. django-widget-tweaks makes this possible by letting you specify CSS classes and additional attributes while rendering form fields in templates with a simple syntax: {% render_field form.title class+="css_class_1 css_class_2" %}.

7. django-passwords

Validating passwords to force the user to use a strong password is a solved problem. Don't reimplement this in your code, just use django-passwords and you can reject passwords below a certain length, present in a dictionary or in a common sequence list.

8. django-role-permissions

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 django-role-permissions this is easily done with a view mixin or a decorator. It's built on top of django.contrib.auth Group and Permission models, so it doesn't add any other models to your project.

9. django-manager-utils

Sometimes you need to get a model or None. django-manager-utils provides you a custom Manager for that. Other additional useful methods are available too.

10. django.js

Ever needed to get a URL from a url name in JavaScript, like from django.core.urlresolvers import reverse does in Python? This can be done with django.js. It also makes it easy to access basic current user info, CSRF token and other stuff.

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!

About Flávio Juvenal

Controversial software developer who questions everything: "Are we really going forward?". Python enthusiast, but is afraid JavaScript will conquer the world. Enjoys working with Django and now wants to write system checks for everything on it.

Comments