I Want to Build Your Website
Follow me here and let me show you what I can do!
Django ManyToMany
One thing that I think is important when it comes to a CMS, is that the CMS be very user friendly. That means that every little thing counts when it comes to the layout and how each of the data elements fit together. We all know that the Django developers have provided us with a great out-of-the-box solution for entering data in the Django admin. However there is one piece that I'm not to thrilled about, and that's the ManyToMany field.
The ManyToMany field is a great feature, and having the ability to add a new relationship from another models interface, is pretty slick, but I'm not to wild about how long lists are managed.
The standard approach for a ManyToMany field in the admin is to give you a select box. That's fine when you have a short list of options, but when your list gets longer, as most lists do, then changing how you implement a ManyToMany field can be beneficial. Luckly for us, Django also provides a solution for this, and it's REALLY easy.
In your admin.py file add the "filter_horizontal = ('your field',)" to your admin class. Once you've done that you'll get something like the following.

As you can see it's a huge improvement from the old select box, and it's easy to do. Remember, it's meant for those fields that end up growing over time. This little javascript widget adds a lot of usability to an otherwise old way of selection multiple options. If your users have to work with the admin often, they will certainly enjoy this simple improvement.
Current Projects
In Production
Recently on twitter
Categories
Archives
Content is licensed under a Creative Commons Public Domain License






Comments
No Response Yet
Why don't YOU kick it off by saying something ↓