Skip to content

Commit 91db70d

Browse files
committed
Fixed uncaught AttributeError if attr doesn't exist
1 parent f379bf0 commit 91db70d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

rest_framework_json_api/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def get_resource_name(context):
3535
if code.startswith('4') or code.startswith('5'):
3636
return 'errors'
3737

38-
resource_name = getattr(view, 'resource_name')
39-
if not resource_name:
38+
try:
39+
resource_name = getattr(view, 'resource_name')
40+
except AttributeError:
4041
try:
4142
# Check the meta class
4243
resource_name = (
@@ -92,7 +93,7 @@ def format_resource_name(obj, name):
9293
"""
9394
Pluralize the resource name if more than one object in results.
9495
"""
95-
if (getattr(settings, 'REST_EMBER_PLURALIZE_KEYS')
96+
if (getattr(settings, 'REST_EMBER_PLURALIZE_KEYS', None)
9697
and isinstance(obj, list)):
9798

9899
return inflection.pluralize(name)

0 commit comments

Comments
 (0)