Skip to content

Commit

Permalink
Remove Django 1.5 get_model_name fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlton Gibson committed Sep 21, 2015
1 parent 4a1ab3c commit 579d4e3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
8 changes: 0 additions & 8 deletions rest_framework/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ def clean_manytomany_helptext(text):
pass


def get_model_name(model_cls):
try:
return model_cls._meta.model_name
except AttributeError:
# < 1.6 used module_name instead of model_name
return model_cls._meta.module_name


# MinValueValidator, MaxValueValidator et al. only accept `message` in 1.8+
if django.VERSION >= (1, 8):
from django.core.validators import MinValueValidator, MaxValueValidator
Expand Down
4 changes: 2 additions & 2 deletions rest_framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.utils import six

from rest_framework.compat import (
distinct, django_filters, get_model_name, guardian
distinct, django_filters, guardian
)
from rest_framework.settings import api_settings

Expand Down Expand Up @@ -202,7 +202,7 @@ def filter_queryset(self, request, queryset, view):
model_cls = queryset.model
kwargs = {
'app_label': model_cls._meta.app_label,
'model_name': get_model_name(model_cls)
'model_name': model_cls._meta.model_name
}
permission = self.perm_format % kwargs
if guardian.VERSION >= (1, 3):
Expand Down
6 changes: 2 additions & 4 deletions rest_framework/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

from django.http import Http404

from rest_framework.compat import get_model_name

SAFE_METHODS = ('GET', 'HEAD', 'OPTIONS')


Expand Down Expand Up @@ -104,7 +102,7 @@ def get_required_permissions(self, method, model_cls):
"""
kwargs = {
'app_label': model_cls._meta.app_label,
'model_name': get_model_name(model_cls)
'model_name': model_cls._meta.model_name
}
return [perm % kwargs for perm in self.perms_map[method]]

Expand Down Expand Up @@ -166,7 +164,7 @@ class DjangoObjectPermissions(DjangoModelPermissions):
def get_required_object_permissions(self, method, model_cls):
kwargs = {
'app_label': model_cls._meta.app_label,
'model_name': get_model_name(model_cls)
'model_name': model_cls._meta.model_name
}
return [perm % kwargs for perm in self.perms_map[method]]

Expand Down

0 comments on commit 579d4e3

Please sign in to comment.