diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index dd2d35ccd..11013fcca 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals from django.http import Http404 +from rest_framework import exceptions from rest_framework.compat import is_authenticated @@ -108,6 +109,10 @@ class DjangoModelPermissions(BasePermission): 'app_label': model_cls._meta.app_label, 'model_name': model_cls._meta.model_name } + + if method not in self.perms_map: + raise exceptions.MethodNotAllowed(method) + return [perm % kwargs for perm in self.perms_map[method]] def has_permission(self, request, view): @@ -169,6 +174,10 @@ class DjangoObjectPermissions(DjangoModelPermissions): 'app_label': model_cls._meta.app_label, 'model_name': model_cls._meta.model_name } + + if method not in self.perms_map: + raise exceptions.MethodNotAllowed(method) + return [perm % kwargs for perm in self.perms_map[method]] def has_object_permission(self, request, view, obj):