mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 14:24:48 +03:00
Added view name to has_permission error message
When this error occurs in a project with a large number of views, it is difficult to pinpoint in which view this error might be happening. By explicitly including the view name in the error message the developer can more easily identify the cause of the problem. Without including this the error message is close to useless as it requires source code analysis or Googling. There are many examples of these kinds of errors in DRF and Django itself, but we have to start somewhere.
This commit is contained in:
parent
c94b354efa
commit
8fdc07a6ca
|
@ -118,9 +118,9 @@ class DjangoModelPermissions(BasePermission):
|
||||||
queryset = getattr(view, 'queryset', None)
|
queryset = getattr(view, 'queryset', None)
|
||||||
|
|
||||||
assert queryset is not None, (
|
assert queryset is not None, (
|
||||||
'Cannot apply DjangoModelPermissions on a view that '
|
'Cannot apply DjangoModelPermissions on view "%s" that '
|
||||||
'does not have `.queryset` property or overrides the '
|
'does not have `.queryset` property or overrides the '
|
||||||
'`.get_queryset()` method.')
|
'`.get_queryset()` method.' % view.get_view_name())
|
||||||
|
|
||||||
perms = self.get_required_permissions(request.method, queryset.model)
|
perms = self.get_required_permissions(request.method, queryset.model)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user