romgar/django-dirtyfields

datetime naive versus aware compare issue

Closed this issue · 3 comments

In 0.8.1, At line 56 in dirtyfields.py, this comparison is failing because of naive vs aware datetimes. The check_relationship flag has the default value set to False.

  1.         if value != original_value:
    

Exception Type: TypeError at ***
Exception Value: can't compare offset-naive and offset-aware datetimes

Hi @samonderous ! Thanks for reporting, I will look into it early January (currently on holidays) !!

@samonderous At the end I'm just wondering if django-dirtyfields should manage this error instead of the end-user.
Trying to compare some data that are not coherent with your backend seems a bit tricky and I'm not convinced it has to be converted under the hood.

@samonderous You can now use compare_function parameter to manage that kind of situation. Doc at http://django-dirtyfields.readthedocs.org/en/develop/#custom-comparison-function, you can use timezone_support_compare function.
It will be in 0.8.2 release.