Repository: wagtail/wagtail

Issue:
Translatable snippets history view breaks with 'Cannot resolve keyword 'locale' into field'.
### Issue Summary

Translatable snippet models history view breaks upon navigating with the exception message:

> FieldError at /admin/snippets/[YOUR_APP_NAME]/[YOUR_MODEL_NAME]/history/1/ 
> Cannot resolve keyword 'locale' into field. Choices are: action, content_changed, content_type, content_type_id, data, deleted, id, label, object_id, revision, revision_id, timestamp, user, user_id, uuid
> **Request Method**: GET
> **Request URL**: http://localhost:5080/admin/snippets/[YOUR_APP_NAME]/[YOUR_MODEL_NAME]/history/1/
> **Django Version**: 4.2.7
> **Exception Type**: FieldError
> **Exception Location**:  [YOUR_PROJECT_PATH]\venv\lib\site-packages\django\db\models\sql\query.py, line 1724, in names_to_path
> **Raised during**: wagtail.snippets.views.snippets.HistoryView

### Steps to Reproduce

1. Create a starter wagtail project (windows/linux)
2. Add `wagtail.contrib.simple_translation`, `wagtail.locales` to the base settings
3. Add `WAGTAIL_I18N_ENABLED = True` and several languages of your choice as `LANGUAGES` / `WAGTAIL_CONTENT_LANGUAGES`. 
4. Add a snippet model of your liking and extend it with the mixins: `WorkflowMixin`, `PreviewableMixin`, `DraftStateMixin`, `RevisionMixin`, `TranslatableMixin`.
5. Make / apply migrations, create super user.
6. In the admin check the **Settings > Locales** if at least one locale is activated. In my case it's just the default 'en-US'.
7. Create an instance of your snippet and publish it.
8. Navigate back to the instance's editor and try opening the history panel.

Here's a small repo with the `Recipe` snippet: https://github.com/happygrizzly/wt_translated_snippets_history_issue.

-   I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes.

### Technical details

-   Python version: 3.11.4 / 3.10.
-   Django version: 4.2.7.
-   Wagtail version: 5.2.
-   Browser version: Latest Firefox, Edge, Chrome.



Discussion:
Thank you! I can confirm this issue using bakerydemo and accessing the History view for the `FooterText` snippet.

Seems to be a regression in dc049cd.

Resolving patch:
diff --git a/wagtail/admin/views/generic/models.py b/wagtail/admin/views/generic/models.py
--- a/wagtail/admin/views/generic/models.py
+++ b/wagtail/admin/views/generic/models.py
@@ -228,7 +228,10 @@ def get_queryset(self):
 
         self.filters, queryset = self.filter_queryset(queryset)
 
-        if self.locale:
+        # Ensure the queryset is of the same model as self.model before filtering,
+        # which may not be the case for views like HistoryView where the queryset
+        # is of a LogEntry model for self.model.
+        if self.locale and queryset.model == self.model:
             queryset = queryset.filter(locale=self.locale)
 
         has_updated_at_column = any(


Test patch:
diff --git a/wagtail/snippets/tests/test_snippets.py b/wagtail/snippets/tests/test_snippets.py
--- a/wagtail/snippets/tests/test_snippets.py
+++ b/wagtail/snippets/tests/test_snippets.py
@@ -61,6 +61,7 @@
     AdvertWithTabbedInterface,
     DraftStateCustomPrimaryKeyModel,
     DraftStateModel,
+    FullFeaturedSnippet,
     MultiPreviewModesModel,
     RevisableChildModel,
     RevisableModel,
@@ -4117,10 +4118,10 @@ def setUp(self):
             timestamp=make_aware(datetime.datetime(2022, 5, 10, 12, 34, 0)),
             object_id="1",
         )
-        self.revisable_snippet = RevisableModel.objects.create(text="Foo")
+        self.revisable_snippet = FullFeaturedSnippet.objects.create(text="Foo")
         self.initial_revision = self.revisable_snippet.save_revision(user=self.user)
         ModelLogEntry.objects.create(
-            content_type=ContentType.objects.get_for_model(RevisableModel),
+            content_type=ContentType.objects.get_for_model(FullFeaturedSnippet),
             label="Foo",
             action="wagtail.create",
             timestamp=make_aware(datetime.datetime(2022, 5, 10, 20, 22, 0)),
@@ -4227,6 +4228,8 @@ def test_with_live_and_draft_status(self):
     def test_get_with_i18n_enabled(self):
         response = self.get(self.non_revisable_snippet)
         self.assertEqual(response.status_code, 200)
+        response = self.get(self.revisable_snippet)
+        self.assertEqual(response.status_code, 200)
 
 
 class TestSnippetRevisions(WagtailTestUtils, TestCase):