v0.137ยค
Featยค
-
Each Component class now has a
class_idattribute, which is unique to the component subclass.NOTE: This is different from
Component.id, which is unique to each rendered instance.To look up a component class by its
class_id, useget_component_by_class_id(). -
It's now easier to create URLs for component views.
Before, you had to call
Component.as_view()and pass that tourlpatterns.Now this can be done for you if you set
Component.Url.publictoTrue:Then, to get the URL for the component, use
get_component_url():This way you don't have to mix your app URLs with component URLs.
Read more on Component views and URLs.
-
Per-component caching - Set
Component.Cache.enabledtoTrueto enable caching for a component.Component caching allows you to store the rendered output of a component. Next time the component is rendered with the same input, the cached output is returned instead of re-rendering the component.
class TestComponent(Component): template = "Hello" class Cache: enabled = True ttl = 0.1 # .1 seconds TTL cache_name = "custom_cache" # Custom hash method for args and kwargs # NOTE: The default implementation simply serializes the input into a string. # As such, it might not be suitable for complex objects like Models. def hash(self, *args, **kwargs): return f"{json.dumps(args)}:{json.dumps(kwargs)}"Read more on Component caching.
-
@djc_testcan now be called without first callingdjango.setup(), in which case it does it for you. -
Expose
ComponentInputclass, which is a typing forComponent.input.
Deprecationยค
-
Currently, view request handlers such as
get()andpost()methods can be defined directly on theComponentclass:Or, nested within the
Component.Viewclass:In v1, these methods should be defined only on the
Component.Viewclass instead.
Refactorยค
Component.get_context_data()can now omit a return statement or returnNone.