django-components/tests/components/multi_file/multi_file.py
Juro Oravec a49f5e51dd
feat: component URL (#1088)
* feat: allow to set defaults

* refactor: remove input validation and link to it

* feat: component URL

* refactor: fix linter errors

* refactor: fix linter errors + update examples to use Component.View..get

* docs: update comment

* refactor: revert change to hash_comp_cls

* docs: update comment
2025-04-07 10:44:41 +02:00

27 lines
855 B
Python

from typing import Any, Dict
from django.http import HttpResponse
from django_components import Component, register
@register("multi_file_component")
class MultFileComponent(Component):
template_file = "multi_file/multi_file.html"
class View:
def post(self, request, *args, **kwargs) -> HttpResponse:
variable = request.POST.get("variable")
return MultFileComponent.render_to_response(
request=request,
kwargs={"variable": variable},
)
def get(self, request, *args, **kwargs) -> HttpResponse:
return MultFileComponent.render_to_response(
request=request,
kwargs={"variable": "GET"},
)
def get_context_data(self, variable, *args, **kwargs) -> Dict[str, Any]:
return {"variable": variable}