Timezone requires 2 arguments, 1 provided

Hello, everyone!

I have a model that stores datetime in UTC format. (My settings.py is on UTC).
In template I want to show to the user the time in his timezone.

djangoproject docs contains a filter example:

timezone
Forces conversion of a single value to an arbitrary timezone.
The argument must be an instance of a tzinfo subclass or a time zone name.
For example:

{% load tz %} 

{{ value|timezone:"Europe/Paris" }} 

But when I use this, it throws an exception:

TemplateSyntaxError at /auction/3

timezone requires 2 arguments, 1 provided

Please, someone can help me to figure what is wrong?

My full code is on github:
The problem is on auctions/templates/auctions/auction.html in comment.createDate

Do you get the same exception with the usage of the tag bellow instead of the filter?

{% timezone "Europe/Paris" %}
    Paris time: {{ value }}
{% endtimezone %}

I don’t see where you have that line in the template named auction.html you are referencing in your post.

Please clarify the issue.

Thanks for replies!

Yeah, I changed it to

{% timezone “xxxxxxx” %}

{% endtimezone %}

and it worked as expected, but not with {{ value| timezone:“Europe/Paris” }} . I think there are an issue in this filter or on the docs.

Great to know, but it will be good to know what’s causing the issue with the timezone filter.
Can you post your django version, middleware and TZ related settings?

Django version: 4.1.1

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'commerce.urls'




# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

We’d also need to see the template demonstrating this issue and the specific view which is rendering the template causing the error.