#NEWLINE# def get_ordering_field( self , field_name ) : #NEWLINE# #INDENT# "\n        Returns the proper model field name corresponding to the given\n        field_name to use for ordering. field_name may either be the name of a\n        proper model field or the name of a method (on the admin or model) or a\n        callable with the 'admin_order_field' attribute. Returns None if no\n        proper model field name can be matched.\n        " #NEWLINE# try : #NEWLINE# #INDENT# field = self . opts . get_field ( field_name ) #NEWLINE# return field . name #NEWLINE# #UNINDENT# except FieldDoesNotExist : #NEWLINE# #INDENT# if callable ( field_name ) : #NEWLINE# #INDENT# attr = field_name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( self . model_admin , field_name ) : #NEWLINE# #INDENT# attr = getattr ( self . model_admin , field_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# attr = getattr ( self . model , field_name ) #NEWLINE# #UNINDENT# #UNINDENT# return getattr ( attr , 'admin_order_field' , None )