# My custom templatetag is not working

**URL:** <https://forum.djangoproject.com/t/my-custom-templatetag-is-not-working/31021>\
**Category:** Templates & Frontend\
**Created:** [May 10, 2024, 5:45am UTC](https://forum.djangoproject.com/t/my-custom-templatetag-is-not-working/31021 "2024-05-10T05:45:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OmidShojaee](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/omidshojaee/32/2216_2.png) [@OmidShojaee](https://forum.djangoproject.com/u/OmidShojaee)\
**Post date:** [May 10, 2024, 5:45am UTC](https://forum.djangoproject.com/t/my-custom-templatetag-is-not-working/31021/1 "2024-05-10T05:45:58Z")

</div>

Hello,

I need to display the current date in Shamsi calendar in multiple templates so I think of a template tag. Looking at the [Django documentation](https://docs.djangoproject.com/en/5.0/howto/custom-template-tags/#simple-tags) I write this in the `shamsi_tags.py` inside `templatetags` folder of my app:

```auto
from datetime import datetime

from django import template

from jdatetime import datetime as jdatetime

register = template.Library()

@register.simple_tag
def shamsi_date():
    """
    This template tag returns the current date in Shamsi format.
    """
    now = datetime.now()
    shamsi_date = jdatetime.fromgregorian(now.year, now.month, now.day)
    return shamsi_date.strftime('%Y/%m/%d')

```

And in my template:

```auto
{% load shamsi_tags %}
...
<div>{{ shamsi_date }}</div>

```

And the output is empty. I check page’s source and I see `<div></div>` only.

What I’m missing?

---

<div class="post-metadata">

**Author:** ![antoinehumbert](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/antoinehumbert/32/14851_2.png) [@antoinehumbert](https://forum.djangoproject.com/u/antoinehumbert)\
**Post date:** [May 10, 2024, 11:43am UTC](https://forum.djangoproject.com/t/my-custom-templatetag-is-not-working/31021/2 "2024-05-10T11:43:24Z")

</div>

Hi, the correct syntax to use tag is `{% shamsi_date %}`. In your example, you try to render a context variable called `shamsi_date`, but the context does not contain such variable, hence the empty result
