# django.shortcuts.get\_object\_or\_404 does not support translation for error messages (i18n)

**URL:** <https://forum.djangoproject.com/t/django-shortcuts-get-object-or-404-does-not-support-translation-for-error-messages-i18n/38268>\
**Category:** Internationalization\
**Created:** [January 27, 2025, 7:39am UTC](https://forum.djangoproject.com/t/django-shortcuts-get-object-or-404-does-not-support-translation-for-error-messages-i18n/38268 "2025-01-27T07:39:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![justbackend](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/justbackend/32/26520_2.png) [@justbackend](https://forum.djangoproject.com/u/justbackend)\
**Post date:** [January 27, 2025, 7:39am UTC](https://forum.djangoproject.com/t/django-shortcuts-get-object-or-404-does-not-support-translation-for-error-messages-i18n/38268/1 "2025-01-27T07:39:28Z")

</div>

```auto
class WheatProvidingViewSet(viewsets.ModelViewSet):
    queryset = WheatProviding.objects.all()
    serializer_class = WheatProvidingSerializer

    def destroy(self, request, *args, **kwargs):
        instance = self.get_object()

```

The code above demonstrates a Django REST Framework (DRF) `ModelViewSet`. When a non-existent ID is provided, the `destroy` method raises a `404 Not Found` error. However, the error message is not translated.

The root cause of this issue is that `ModelViewSet` relies on Django’s `get_object_or_404` function, which does not support internationalization (i18n) for its error messages.

Could you consider adding support for translations in the `get_object_or_404` function? This enhancement would allow DRF to natively support localized error messages, improving its usability in multilingual applications.

---

<div class="post-metadata">

**Author:** ![claudep](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/claudep/32/5377_2.png) [@claudep](https://forum.djangoproject.com/u/claudep)\
**Post date:** [January 27, 2025, 8:00am UTC](https://forum.djangoproject.com/t/django-shortcuts-get-object-or-404-does-not-support-translation-for-error-messages-i18n/38268/2 "2025-01-27T08:00:14Z")

</div>

Thanks for the suggestion. I would be in favor of translating the message `"No %s matches the given query."` in the various functions in shortcuts, as this string is susceptible to be user-facing (which is the current rule for Django to decide if a string is translated or not).

Could you please open an issue in the Django ticket tracker to suggest that improvement?

---

<div class="post-metadata">

**Author:** ![justbackend](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/justbackend/32/26520_2.png) [@justbackend](https://forum.djangoproject.com/u/justbackend)\
**Post date:** [January 27, 2025, 8:31am UTC](https://forum.djangoproject.com/t/django-shortcuts-get-object-or-404-does-not-support-translation-for-error-messages-i18n/38268/4 "2025-01-27T08:31:17Z")

</div>

opened an issue in the Django ticket tracker, thank you guys
