django_unicorn.views#

Subpackages#

Submodules#

Package Contents#

django_unicorn.views.MIN_VALIDATION_ERROR_ARGS = 2#
django_unicorn.views.handle_error(view_func)#

Returns a JSON response with an error if necessary.

django_unicorn.views.message(request: django.http.HttpRequest, component_name: Optional[str] = None) django.http.JsonResponse#

Endpoint that instantiates the component and does the correct action (set an attribute or call a method) depending on the JSON payload in the body.

Parameters:
  • request (param) – HttpRequest for the function-based view.

  • param – component_name: Name of the component, e.g. “hello-world”.

Returns:

{ “id”: component_id, “dom”: html, # re-rendered version of the component after actions in the payload are completed “data”: {}, # updated data after actions in the payload are completed “errors”: {}, # form validation errors “return”: {}, # optional return value from an executed action “parent”: {} # optional representation of the parent component }

Return type:

JsonRequest with the following structure in the body