SmarterJournaledJsonResponse

class smarter.lib.journal.http.SmarterJournaledJsonResponse(request, data, encoder=<class 'smarter.lib.json.SmarterJSONEncoder'>, safe=True, thing=None, command=None, json_dumps_params=None, status=200, **kwargs)[source]

Bases: JsonResponse, SmarterHelperMixin

An enhanced HTTP response class for the Smarter API that augments standard Django JSON responses with additional manifest structure and metadata.

This class is designed to provide a consistent response format for all Smarter API endpoints, embedding contextual information about the request and operation performed. It automatically attaches metadata such as the API version, the entity (“thing”) being operated on, and the command executed. When journaling is enabled, it also creates a corresponding journal entry in the database, capturing the request, response, user, and status code for audit and traceability.

Smarter-specific parameters include the original Django request object, the noun (“thing”) being journaled, the command performed, and the API response data. Standard Django JsonResponse parameters such as data, encoder, safe, and json_dumps_params are also supported.

Example

A typical response data structure produced by this class:

{
    "api": "v1",
    "thing": "account",
    "metadata": {
        "command": "create"
    }
}

When journaling is active, the metadata may also include a unique journal key for the entry.

See also

SAMJournal, django.http.JsonResponse, smarter.common.utils.hash_factory(), smarter.lib.django.http.serializers

__init__(request, data, encoder=<class 'smarter.lib.json.SmarterJSONEncoder'>, safe=True, thing=None, command=None, json_dumps_params=None, status=200, **kwargs)[source]