mirror of
https://github.com/django-components/django-components.git
synced 2025-08-30 18:57:20 +00:00
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
This commit is contained in:
parent
3555411f1e
commit
a49f5e51dd
37 changed files with 987 additions and 314 deletions
|
@ -1,3 +1,4 @@
|
|||
import time
|
||||
from typing import Any, Dict
|
||||
|
||||
from django_components import Component, register, types
|
||||
|
@ -5,17 +6,18 @@ from django_components import Component, register, types
|
|||
|
||||
@register("recursive")
|
||||
class Recursive(Component):
|
||||
def get(self, request):
|
||||
import time
|
||||
time_before = time.time()
|
||||
output = self.render_to_response(
|
||||
kwargs={
|
||||
"depth": 0,
|
||||
},
|
||||
)
|
||||
time_after = time.time()
|
||||
print("TIME: ", time_after - time_before)
|
||||
return output
|
||||
class View:
|
||||
def get(self, request):
|
||||
time_before = time.time()
|
||||
output = Recursive.render_to_response(
|
||||
request=request,
|
||||
kwargs={
|
||||
"depth": 0,
|
||||
},
|
||||
)
|
||||
time_after = time.time()
|
||||
print("TIME: ", time_after - time_before)
|
||||
return output
|
||||
|
||||
def get_context_data(self, depth: int = 0) -> Dict[str, Any]:
|
||||
return {"depth": depth + 1}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue