Bug patches for django-voting and django-tagging

As part of my top-secret Django project, I’ve enlisted the help of the django-voting and django-tagging packages to provide rating and tagging, respectively, to my models. These work wonders and serve their purpose to a T, however, I’ve come across a couple small bugs that I wanted to document here, in addition to the bug reports I’ve posted.

django-voting get_scores_in_bulk breaks when objects is empty

The get_scores_in_bulk method is provided to, surprisingly, retrieve the scores from a group of objects in bulk. It’s passed the object_list that you get from Django’s generic views. If you have the allow_empty parameter set on the generic view, then this variable may be empty. The bug is that the get_scores_in_bulk method assumes that there’s at least 1 object in the list, causing an IndexError if that’s not true. The patch linked below adds a check for this condition and causes everything to work.

Bug Report, Patch

django-tagging allow_empty not supported in tagged_object_list

The allow_empty parameter is listed as being supported in the package’s overview.txt, however, it has no effect. Just like in Django generic views, the parameter, when set to True shows the template even when there are no objects being shown. In my case, I wanted to show the user some other options instead of sending them a 404 error.

The bug is that the allow_empty parameter isn’t taken into consideration at all. The patch linked below changes the code to check allow_empty before raising a 404 error. The 404 now only happens if allow_empty is not present or false.

Bug Report, Patch

[update: The django-voting bug has been patched and now the trunk is good to go!]

Possibly Related Posts

Comments are closed.