Skip to content

Conversation

njamaleddine
Copy link
Contributor

@njamaleddine njamaleddine commented May 6, 2017

Description

Add ValidationError to except in rest_framework.generics.get_object_or_404 to handle change in Django 1.11 where get_object_or_404 returns a ValidationError (as opposed to earlier versions that returned a ValueError) when passing an invalid value for the uuid.

Refs #3377 (I'd be happy to open up a separate issue for this as well, but wasn't sure if I should)

@xordoquy xordoquy merged commit a251b93 into encode:master May 11, 2017
@xordoquy xordoquy added this to the 3.6.3 Release milestone May 11, 2017
@xordoquy
Copy link
Contributor

Thank you for the fix.

try:
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
except (TypeError, ValueError):
except (TypeError, ValueError, ValidationError):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it re-raise it as a DRF validation error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is get_object_or_404, the raise Http404 here is to keep it consistent with the get_object_or_404 method that is implemented within the Django core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants