[Django]-How do I pass custom variable values to the django admin interface?

8👍

✅

According to my understanding of your question.I hope this will help you.
Create this directory structure inside any app.
templatetags
templatetags/init.py
templatetags/sum.py

from django import template

register = template.Library()

@register.simple_tag
def get_sum(a, b):
    return a+b

Now copy a base_site.html inside your template folder from django source code in the structure.

-admin
-base_site.html
paste this on the top of html

{% load  sum %}

now paste this where you want

{% with a=10 b=90 %}  
    Sum is here: {% get_sum a b %}
{% endwith %}

You can create any function instaed of sum.

Leave a comment