Print Format Jinja Issue

In my project I need to convert from Gregorian to Arabic Hijri date, I need to print the current printing date in Hijri
This is my code, I use umalqurra library for that:

from umalqurra.hijri_date import HijriDate
import datetime

def hijry():
	datee = datetime.datetime.strptime(, "%Y-%m-%d")
	um = HijriDate(datee.year,datee.month,,gr=True)
	print int(um.year), um.month_name , int(

I change this code to jinja like follow:

{% set datee = datetime.datetime.strptime(, "%Y-%m-%d") %}
{% set um = HijriDate(datee.year,datee.month,,gr=True) %}        
{{ int( }}

When I check print format, it shows this error

UndefinedError: ‘datetime’ is undefined

I try to include it in jinja like this :

{% import datetime %}
{% from umalqurra.hijri_date import HijriDate %}

But it still the same!
Any solution

1 Like

We only allow limited methods in Jinja for security reasons.


1 Like

I solve it by adding my function in the utils with importing code
and then call it in jinja using
{{ frappe.get_hijry() }}

1 Like

it will get overwritten next bench update …

1 Like

try to create ur method in ur custom app dont update in frappe codebase it will be overwritten when u do bench update

1 Like

@hereabdulla @JoEz
thanks , we chose stable frappe to be fixed in project