mirror of
https://github.com/django-components/django-components.git
synced 2025-08-27 01:14:04 +00:00

* refactor: update docs and tests to use get_template_data() * refactor: fix linting * docs: add note about difference between the two methods
27 lines
869 B
Python
27 lines
869 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_template_data(self, args, kwargs, slots, context) -> Dict[str, Any]:
|
|
return {"variable": kwargs["variable"]}
|