How does this work since you are already setting header_template using setattr in the line earlier. Maybe this should happen before the setattr?