#NEWLINE# def get_fields_from_path( model , path ) : #NEWLINE# #INDENT# ' Return list of Fields given path relative to model.\n\n    e.g. (ModelX, "user__groups__name") -> [\n        <django.db.models.fields.related.ForeignKey object at 0x...>,\n        <django.db.models.fields.related.ManyToManyField object at 0x...>,\n        <django.db.models.fields.CharField object at 0x...>,\n    ]\n    ' #NEWLINE# pieces = path . split ( LOOKUP_SEP ) #NEWLINE# fields = [ ] #NEWLINE# for piece in pieces : #NEWLINE# #INDENT# if fields : #NEWLINE# #INDENT# parent = get_model_from_relation ( fields [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# parent = model #NEWLINE# #UNINDENT# fields . append ( parent . _meta . get_field_by_name ( piece ) [ 0 ] ) #NEWLINE# #UNINDENT# return fields