django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

DateTimeField raises NonExistentTimeError/AmbiguousTimeError during validation.

Open halfstrik opened this issue 9 years ago • 3 comments

Checklist

  • [x] I have verified that that issue exists against the master branch of Django REST framework.
  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] This is not a usage question. (Those should be directed to the discussion group instead.)
  • [x] This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • [x] I have reduced the issue to the simplest possible case.
  • [x] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

  1. Intall pytz (along with Django and django-rest-framwork);
  2. Set settings.TIME_ZONE = 'America/New_York';
  3. Make a serializor with DateTimeField;
  4. Try to serialize '2017-03-12T02:30:00'.

or

  1. Execute DateTimeField(default_timezone=pytz.timezone('America/New_York')).to_internal_value('2017-03-12T02:30:00')

Expected behavior

ValidationError raised with appropriate message.

Actual behavior

NonExistentTimeError/AmbiguousTimeError propagated from pytz.

halfstrik avatar Mar 16 '17 04:03 halfstrik

Good catch, indeed it should return a ValidationError

xordoquy avatar Mar 16 '17 06:03 xordoquy

Okay, since #4987 is merged do we still have addressing AmbiguousTimeError to resolve, or are we done here?

lovelydinosaur avatar Apr 27 '17 16:04 lovelydinosaur

From my understanding we're all set here, feel free to close this one

halfstrik avatar Apr 28 '17 03:04 halfstrik