[Fixed]-Django – display method result without url

1👍

✅

If I understand what you want to do, I think you should use a general template which will be extended for every other page you want to display.

You can achieve that using Jinja template engine adding:

{% extends 'general.html' %}

in every template you want to display credits

For example:

general.html

<head>
    {% block head %}
    <title>General</title>
    {% endblock %}
</head>

<body>
    <p>{{ user.credit }}</p>

    {% block body %}
    <h1>General</h1>
    {% endblock %}
</body>

another-template.html:

{% extends 'general.html' %}

<head>
    {% block head %}
    <title>Another template</title>
    {% endblock %}
</head>

<body>
    {% block body %}
    <h1>Another template</h1>
    {% endblock %}
</body>

Second template will overwrite “block head” and “block body” content, but still display credit from general.html.

Leave a comment