duck.contrib.responses.template_responseΒΆ

This module provides a shortcut to create a better-mid response with a given response class and icon link.

Module ContentsΒΆ

FunctionsΒΆ

template_response

Transforms a basic response like HttpServerErrorResponse into a nicer Duck response.

DataΒΆ

FAVICON

APIΒΆ

duck.contrib.responses.template_response.FAVICONΒΆ

None

duck.contrib.responses.template_response.template_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link=FAVICON, icon_type='image/png', debug: bool = SETTINGS['DEBUG']) β†’ duck.http.response.TemplateResponseΒΆ

Transforms a basic response like HttpServerErrorResponse into a nicer Duck response.

Parameters:
  • response_class – The response class to be transformed.

  • title – The title of the response, If not provided, response.status_message is used (optional).

  • heading – The heading of the response. If not provided, response.status_message is used (optional).

  • body – The body of the response. If not provided, response.status_explanation is used (optional).

  • icon_link – The link to the icon (optional).

  • icon_type – The type of the icon (optional).

  • debug – Whether to render template in debug mode. Defaults to the one set in settings.py

Returns:

The transformed response.

Return type:

TemplateResponse