mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 09:57:55 +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:
 | 
			
		||||
        # Nod to tastypie's use of importlib.
 | 
			
		||||
        parts = val.split('.')
 | 
			
		||||
        module_path, class_name = '.'.join(parts[:-1]), parts[-1]
 | 
			
		||||
        module_path, class_name = val.rsplit('.', 1)
 | 
			
		||||
        module = import_module(module_path)
 | 
			
		||||
        return getattr(module, class_name)
 | 
			
		||||
    except (ImportError, AttributeError) as e:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user