Commit 0ec48c52 by Alex Gaynor

Updated for 2.4 compatibility, thanks Charles.

parent 15645ff6
......@@ -4,6 +4,9 @@ Welcome to django-taggit's documentation!
``django-taggit`` is a reusable Django application designed to making adding
tagging to your project easy and fun.
``django-taggit`` works with Django 1.1 and 1.2 (see the issues documentation
for known issues with older versions of Django), and Python 2.4-2.X.
.. toctree::
:maxdepth: 2
......
from collections import defaultdict
import django
from django.contrib.contenttypes.generic import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
......@@ -13,6 +11,12 @@ from taggit.models import Tag, TaggedItem
from taggit.utils import require_instance_manager
try:
all
except NameError:
# 2.4 compat
from django.utils.itercompat import all
class TaggableRel(ManyToManyRel):
def __init__(self, to):
......@@ -183,8 +187,9 @@ class _TaggableManager(models.Manager):
for obj in objs:
items[(getattr(obj, f.rel.field_name),)] = obj
else:
preload = defaultdict(set)
preload = {}
for result in qs:
preload.setdefault(result['content_type'], set())
preload[result["content_type"]].add(result["object_id"])
for ct, obj_ids in preload.iteritems():
......
from __future__ import with_statement
from contextlib import contextmanager
from django.test import TestCase
from taggit.models import Tag, TaggedItem
......@@ -16,16 +13,6 @@ class BaseTaggingTest(TestCase):
tags.sort()
self.assertEqual(got, tags)
@contextmanager
def assert_raises(self, exc_type):
try:
yield
except Exception, e:
self.assert_(type(e) is exc_type, "%s didn't match expected "
"exception type %s" % (e, exc_type))
else:
self.fail("No exception raised, expected %s" % exc_type)
class TaggableManagerTestCase(BaseTaggingTest):
food_model = Food
......@@ -66,10 +53,9 @@ class TaggableManagerTestCase(BaseTaggingTest):
apple.delete()
self.assert_tags_equal(self.food_model.tags.all(), ["green"])
f = self.food_model()
with self.assert_raises(ValueError):
f.tags.all()
food_instance = self.food_model()
self.assertRaises(ValueError, lambda: food_instance.tags.all())
def test_unique_slug(self):
apple = self.food_model.objects.create(name="apple")
......
from functools import wraps
from django.utils.functional import wraps
def parse_tags(tags):
if tags is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment