[Fixed]-How to extend Django CMS template?

1👍

you have to put your code inside the block content . The extended template overwrites the blocks in the base template.

<div class="container">
    {% block content %}
    {% endblock %}
</div>
    {% block js_bottom %}
    {% endblock %}

_hello.html

{% extends 'base.html' %}
{% block content %}
<div class="row">
    <div class="col-md-12 text-center"><h2>Survey About Computer Programming</h2></div>
</div>
<div class="row">
    <div class="col-md-12">
        <h3>Programming</h3>
        <table class="table table-bordered table-striped table-responsive">
            <thead>
                <tr align="center">
                    <th>Main</th>
                    <th class="text-center">Option1</th>
                    <th class="text-center">Option2</th>
                    <th class="text-center">Option3</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Do you love Programming?</td>
                    <td class="text-center"><input type="radio" class=""></td>
                    <td class="text-center"><input type="radio" class=""></td>
                    <td class="text-center"><input type="radio" class=""></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
    {% endblock %}

{% block js_bottom %}
<script src="/static/survey/js/plugin.js"></script>
{% endblock %}
👤Alex

0👍

You Missed important thing whenver we are creating template like this we have to make sure every block like CSS, Content, JS must be defined proporly in base html file. And when you extends this base template then you have to framed your content as per requirement. Like if you need to put some content in the html page which extends the base html simply call as following
{% block _block_name_should_be_here %}
{% endblock %}

Block name might be like css_part , content_part , js_part which needs to be used the html page.

Leave a comment