#NEWLINE# def resolve_orm_path( model , orm_path ) : #NEWLINE# #INDENT# '\n    Follows the queryset-style query path of ``orm_path`` starting from ``model`` class.  If the\n    path ends up referring to a bad field name, ``django.db.models.fields.FieldDoesNotExist`` will\n    be raised.\n\n    ' #NEWLINE# bits = orm_path . split ( '__' ) #NEWLINE# endpoint_model = reduce ( get_model_at_related_field , ( [ model ] + orm_path [ : ( - 1 ) ] ) ) #NEWLINE# if ( bits [ ( - 1 ) ] == 'pk' ) : #NEWLINE# #INDENT# field = endpoint_model . _meta . pk #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( field , _ , _ , _ ) = endpoint_model . _meta . get_field_by_name ( bits [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# return field