when using get_object_or_404 you can not translate the error #9408
Unanswered
hosseinmp76
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
DRF uses its own get_object_or_404 that uses DJango's get_object_or_404 under the hood. the problem is in django code:
https://github.com/django/django/blob/8f205acea94e93a463109e08814f78c09307f2b9/django/shortcuts.py#L88
It does not use translation. so that DRF gets is an english string for error:
django-rest-framework/rest_framework/generics.py
Line 13 in 36d5c0e
So as I understood there is no easy way to translate the error unless overwriting get_object_or_404 of DRF and using a custom get_object_or_404 instead of Django's one.
Beta Was this translation helpful? Give feedback.
All reactions