mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-18 04:20:53 +03:00
using rsplit to get module and classname for imports (#5712)
This commit is contained in:
parent
0712094ea2
commit
6b0bf72bb8
|
@ -179,8 +179,7 @@ def import_from_string(val, setting_name):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Nod to tastypie's use of importlib.
|
# Nod to tastypie's use of importlib.
|
||||||
parts = val.split('.')
|
module_path, class_name = val.rsplit('.', 1)
|
||||||
module_path, class_name = '.'.join(parts[:-1]), parts[-1]
|
|
||||||
module = import_module(module_path)
|
module = import_module(module_path)
|
||||||
return getattr(module, class_name)
|
return getattr(module, class_name)
|
||||||
except (ImportError, AttributeError) as e:
|
except (ImportError, AttributeError) as e:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user