Skip to content

Latest commit

 

History

History
82 lines (45 loc) · 1.8 KB

File metadata and controls

82 lines (45 loc) · 1.8 KB

get_private_thread_detail_view_thread_queryset_hook

This hook wraps the standard function that Misago uses to get a queryset used to get a thread for the private thread detail view.

Location

This hook can be imported from misago.privatethreads.hooks:

from misago.privatethreads.hooks import get_private_thread_detail_view_thread_queryset_hook

Filter

def 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.

Arguments

action: GetPrivateThreadDetailViewThreadQuerysetHookAction

Next function registered in this hook, either a custom function or Misago's standard one.

See the action section for details.

request: HttpRequest

The request object.

Return value

A QuerySet instance to use in the get_object_or_404 call.

Action

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.

Arguments

request: HttpRequest

The request object.

Return value

A QuerySet instance to use in the get_object_or_404 call.

Example

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")