Commit 10923624 by Florian Apolloner

Fixed 1.7 deprecation warnings.

parent 095cb153
......@@ -21,6 +21,13 @@ from taggit.models import TaggedItem, GenericTaggedItemBase
from taggit.utils import require_instance_manager
def _model_name(model):
if VERSION < (1, 7):
return model._meta.module_name
else:
return model._meta.model_name
class TaggableRel(ManyToManyRel):
def __init__(self, field):
self.related_name = None
......@@ -128,7 +135,7 @@ class TaggableManager(RelatedField, Field):
return self.through.objects.none()
def related_query_name(self):
return self.model._meta.module_name
return _model_name(self.model)
def m2m_reverse_name(self):
return self.through._meta.get_field_by_name("tag")[0].column
......@@ -167,7 +174,8 @@ class TaggableManager(RelatedField, Field):
return [("%s__content_type__in" % prefix, cts)]
def get_extra_join_sql(self, connection, qn, lhs_alias, rhs_alias):
if rhs_alias == '%s_%s' % (self.through._meta.app_label, self.through._meta.module_name):
model_name = _model_name(self.through)
if rhs_alias == '%s_%s' % (self.through._meta.app_label, model_name):
alias_to_join = rhs_alias
else:
alias_to_join = lhs_alias
......
......@@ -12,7 +12,7 @@ from django.utils.encoding import force_text
from django.contrib.contenttypes.models import ContentType
from taggit.managers import TaggableManager
from taggit.managers import TaggableManager, _model_name
from taggit.models import Tag, TaggedItem
from .forms import (FoodForm, DirectFoodForm, CustomPKFoodForm,
OfficialFoodForm)
......@@ -285,7 +285,7 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
spot.tags.add('scary')
spike.tags.add('fluffy')
lookup_kwargs = {
'%s__name' % self.pet_model._meta.module_name: 'Spot'
'%s__name' % _model_name(self.pet_model): 'Spot'
}
self.assert_tags_equal(
self.tag_model.objects.filter(**lookup_kwargs),
......
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