mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
Add documentation of settings.
This commit is contained in:
parent
475bc8720f
commit
3ac77f563b
1 changed files with 28 additions and 4 deletions
32
README.md
32
README.md
|
@ -56,7 +56,7 @@ TEMPLATES = [
|
|||
|
||||
# Contributors
|
||||
|
||||
<!-- readme: contributors -start -->
|
||||
<!-- readme: contributors -start -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
|
@ -257,9 +257,13 @@ NOTE: `{% csrf_token %}` tags need access to the top-level context, and they wil
|
|||
|
||||
Components can also access the outer context in their context methods by accessing the property `outer_context`.
|
||||
|
||||
# Configuring the library location
|
||||
# Available settings
|
||||
|
||||
If you want to, you can configure the location where components are loaded. To do this, add a COMPONENTS variable to you settings.py with a list of libraries to look for. This allows you to build a structure of components that are independent from your apps.
|
||||
All library settings are handled from a global COMPONENTS variable that is read from settings.py. By default you don't need it set, there are resonable defaults.
|
||||
|
||||
## Configure the module where components are loaded from
|
||||
|
||||
Configure the location where components are loaded. To do this, add a COMPONENTS variable to you settings.py with a list of python paths to load. This allows you to build a structure of components that are independent from your apps.
|
||||
|
||||
```python
|
||||
COMPONENTS = {
|
||||
|
@ -267,7 +271,27 @@ COMPONENTS = {
|
|||
"mysite.components.forms",
|
||||
"mysite.components.buttons",
|
||||
"mysite.components.cards",
|
||||
]
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
## Disable autodiscovery
|
||||
|
||||
If you specify all the component locations with the setting above and have a lot of apps, you can (very) slightly speed things up by disabling autodiscovery.
|
||||
|
||||
```python
|
||||
COMPONENTS = {
|
||||
"autodiscovery": False,
|
||||
}
|
||||
```
|
||||
|
||||
## Tune the template cache
|
||||
|
||||
Each time a template is rendered it is cached to a global in-memory cache (using Python's lru_cache decorator). This speeds up the next render of the component. As the same component is often used many times on the same page, these savings add up. By default the cache holds 128 component templates in memory, which should be enough for most sites. But if you have a lot of components, or if you are using the `template` method of a component to render lots of dynamic templates, you can increase this number. To remove the cache limit altogether and cache everything, set template_cache_size to `None`.
|
||||
|
||||
```python
|
||||
COMPONENTS = {
|
||||
"template_cache_size": 256,
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue