This hook wraps the standard function that Misago uses to get a queryset used to get a thread for the private thread detail view.
This hook can be imported from misago.privatethreads.hooks:
from misago.privatethreads.hooks import get_private_thread_detail_view_thread_queryset_hookdef custom_get_private_thread_detail_view_thread_queryset_filter(
action: GetPrivateThreadDetailViewThreadQuerysetHookAction,
request: HttpRequest,
) -> QuerySet:
...A function implemented by a plugin that can be registered in this hook.
Next function registered in this hook, either a custom function or Misago's standard one.
See the action section for details.
The request object.
A QuerySet instance to use in the get_object_or_404 call.
def get_private_thread_detail_view_thread_queryset_action(request: HttpRequest) -> QuerySet:
...Misago function used to get a queryset used to get a thread for the private thread detail view.
The request object.
A QuerySet instance to use in the get_object_or_404 call.
The code below implements a custom filter function that joins plugin's table with select_related:
from django.http import HttpRequest
from misago.privatethreads.hooks import get_private_thread_detail_view_thread_queryset_hook
@get_private_thread_detail_view_thread_queryset_hook.append_filter
def select_related_plugin_data(action, request: HttpRequest):
queryset = action(request)
return queryset.select_related("plugin")