mirror of
https://github.com/django-components/django-components.git
synced 2025-09-23 14:12:27 +00:00

* 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
27 lines
855 B
Python
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}
|