I'm working on django api using a PostgreSQL database. The model has a date field representing a travel time (in jalali format) and an integer field representing number of passengers for that travel.
I'm using django_jalali to handle jalali date queries.
from django_jalali.db import models as jmodels
class TravelReport( models.Model ):
travel_date = jmodels.jDateField(verbose_name="تاریخ سفر")
passengers = models.IntegerField()
I want to aggregate sum of passengers for each week number in a jalali year. This is the query I'm using:
queryset= TravelReport.objects.annotate(week=F("travel_date__week")).values("week").annotate(total_passengers=Sum("passengers"))
Here is my problem: Django lookup __week is returning Georgian week number not jalali week number. For example week number for a travel date with jdatetime.date(1390, 5, 12) should be 19 but my query is returning 31.
What are my options to fix this?
Ok. Lets work out options: