Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Django-Jinja2 template engine support. #42

Open
denis-trofimov opened this issue Dec 11, 2018 · 1 comment
Open

Add Django-Jinja2 template engine support. #42

denis-trofimov opened this issue Dec 11, 2018 · 1 comment

Comments

@denis-trofimov
Copy link

A feature proposal.

I have a need to implement Django-Jinja2 template engine support.
I plan to use it in commercial product and I am at a deadline.
I have read Writing Extensions Create Jinja extensions and I don't know how solve it myself.

@denis-trofimov
Copy link
Author

I solved with this small JS jsTimezoneDetect from Jon Nylander.
I pass jstz timezone name to a hidden form field value.
In Django backend call I have this so called "MVP" unpolished code.

            try:
                current_tz = pytz.timezone(post.get('timezone_name'))
            except:
                current_tz = timezone.get_current_timezone()

            try:
                naive_datetime = timezone.datetime.strptime(
                        post.get('date'), '%d.%m.%Y'
                ) + timezone.timedelta(
                    hours=int(post.get('time')[0:2]),
                    minutes=int(post.get('time')[3:])
                )
                call_date = current_tz.localize(naive_datetime)
            except:
                pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants