(self, model_class, field_name, path="", path_verbose="")
return (new_fields, model_ct, path)
Get fields for a given model
Get fields for a given model
Get fields for a given model
def get_related_fields(self, model_class, field_name, path="", path_verbose=""):
        """ Get fields for a given model """
        if field_name:
            field = model_class._meta.get_field(field_name)
            direct = field.concrete
            if direct:
                try:
                    related_field = field.remote_field
                except AttributeError:
                    # Needed for Django < 1.9
                    related_field = field.related
                try:
                    new_model = related_field.parent_model()
                except AttributeError:
                    new_model = related_field.model
            else:
                # Indirect related field
                new_model = field.related_model

            if path_verbose:
                path_verbose += "::"
            path_verbose += field.name

            path += field_name
            path += '__'
        else:
            new_model = model_class

        new_fields = get_relation_fields_from_model(new_model)
        model_ct = ContentType.objects.get_for_model(new_model)

        return (new_fields, model_ct, path)
def get_related_fields ( self , model_class , field_name , path = "" , path_verbose = "" ) : if field_name : field = model_class . _meta . get_field ( field_name ) direct = field . concrete if direct : try : related_field = field . remote_field except AttributeError : # Needed for Django < 1.9 related_field = field . related try : new_model = related_field . parent_model ( ) except AttributeError : new_model = related_field . model else : # Indirect related field new_model = field . related_model if path_verbose : path_verbose += "::" path_verbose += field . name path += field_name path += '__' else : new_model = model_class new_fields = get_relation_fields_from_model ( new_model ) model_ct = ContentType . objects . get_for_model ( new_model ) return ( new_fields , model_ct , path )