from django import template

from homepage.models import Tab

register = template.Library()

@register.tag(name="get_tabs")
def get_tabs(parser, token):
    
    return GetElementNode()
    
class GetElementNode(template.Node):
    
        def __init__(self):
            pass
            
        def render(self, context):
            context['tabs'] = Tab.objects.all()
            return ''
from django import template

from homepage.models import Tab

register = template.Library()

@register.tag(name="get_tabs")
def get_tabs(parser, token):
    
    return GetElementNode()
    
class GetElementNode(template.Node):
    
        def __init__(self):
            pass
            
        def render(self, context):
            context['tabs'] = Tab.objects.all().select_related('grid')
            return ''
Reduce queries on all pages by using select_related in the get_tabs template tag.