Search code examples
djangopostgresqldjango-rest-frameworkdjango-jsonfield

how can i filter field django jsonfield that is datetime?


I want to filter base on time field in jsonfield,but this field store as string and i can not use this query:

Notification.objects.filter(Q(data__payload__request_visit_time__gte=timezone.now()))

Solution

  • By comments of this post it seems to be possible if you pass datetime value in your query as string:

    Notification.objects.filter(Q(data__payload__request_visit_time__gte=timezone.now().isoformat()))