django-haystack / django-haystack/django-haystack

Haystack date indexes are not storing timezone information

Open
#1,591 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
1.3k
Avg merge
3h 18m
Merged PRs (30d)
3

Description

  • Tested with the latest Haystack release
  • Tested with the current Haystack master branch

Expected behaviour

'published' should have timezone included and for UTC should get something like: 2018-02-17T02:14:53.343690Z

Actual behaviour

But what I get is: 2018-02-17T02:14:53 from haystack. When I query my DB model, I get the correct value with timezone information.

Steps to reproduce the behaviour

published = indexes.DatetimeField(model_attr='publish_date')
USE_TZ=True

Configuration

  • Operating system version: ubuntu:14.04
  • Search engine version: ES 2.0.0
  • Python version: 2.7.6
  • Django version: 1.8
  • Haystack version: latest version

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the indexes.DatetimeField case with USE_TZ=True and Elasticsearch 2.0, comparing the indexed date with the Django model value. Then inspect Haystack's DatetimeField and Elasticsearch backend handling of datetime serialization. Done means the indexed published value retains timezone information, including the expected UTC form.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, elasticsearch, python
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.