for every f in opts.local_fields that has an 'post_create_sql' attribute, append f to a list, substitute the resulting list for post_sql_fields.
post_sql_fields = [ f for f in opts . local_fields if hasattr ( f , 'post_create_sql' ) ]