mirror of
https://github.com/django-components/django-components.git
synced 2025-08-11 17:57:59 +00:00
chore: init docs
This commit is contained in:
parent
899b9a2738
commit
163b0941c2
49 changed files with 1447 additions and 9 deletions
22
docs/user_guide/creating_using_components/middleware.md
Normal file
22
docs/user_guide/creating_using_components/middleware.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Setting Up `ComponentDependencyMiddleware`
|
||||
|
||||
[`ComponentDependencyMiddleware`][django_components.middleware.ComponentDependencyMiddleware] is a Django middleware designed to manage and inject CSS/JS dependencies for rendered components dynamically. It ensures that only the necessary stylesheets and scripts are loaded in your HTML responses, based on the components used in your Django templates.
|
||||
|
||||
To set it up, add the middleware to your [`MIDDLEWARE`][] in settings.py:
|
||||
|
||||
```python
|
||||
MIDDLEWARE = [
|
||||
# ... other middleware classes ...
|
||||
'django_components.middleware.ComponentDependencyMiddleware'
|
||||
# ... other middleware classes ...
|
||||
]
|
||||
```
|
||||
|
||||
Then, enable `RENDER_DEPENDENCIES` in setting.py:
|
||||
|
||||
```python
|
||||
COMPONENTS = {
|
||||
"RENDER_DEPENDENCIES": True,
|
||||
# ... other component settings ...
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue