I created a reusable function for changing block name in Djago templates. I want to know if the code is good or is there any probable issues in it. I developed the function as a hack for the following issue.Template Code{% extends base_name %}{% block main-contents %}    <h2>{{ message_heading }}</h2>    <div class=alert alert-{{ box_color|default:info }}>        {{ message }}        {% if btn_1_text and btn_1_url %}            <a href={{ btn_1_url }} class=btn btn-{{ btn_1_color }}>{{ btn_1_text }}</a>        {% endif %}        {% if btn_2_text and btn_2_url %}            <a href={{ btn_2_url }} class=btn btn-{{ btn_2_color }}>{{ btn_2_text }}</a>        {% endif %}    </div>{% endblock %}Function to change block namedef change_block_names(template, change_dict):        This function will rename the blocks in the template from the    dictionary. The keys in th change dict will be replaced with    the corresponding values. This will rename the blocks in the     extended templates only.        extend_nodes = template.nodelist.get_nodes_by_type(ExtendsNode)    if len(extend_nodes) == 0:        return    extend_node = extend_nodes[0]    blocks = extend_node.blocks    for name, new_name in change_dict.items():        if blocks.has_key(name):            block_node = blocks[name]            block_node.name = new_name            blocks[new_name] = block_node            del blocks[name]tmpl_name = 'django-helpers/twitter-bootstrap/message.html'tmpl1 = loader.get_template(tmpl_name)change_block_names(tmpl1, {'main-contents': 'new-main-contents'})return HttpResponse(tmpl.render(Context()))This function seems to work for my issue. But I don't know if this breaks any of the Django's functionality. Can anyone verify this and give me some advice?
Django template block name changing function
python;django