mirror of
https://github.com/django-components/django-components.git
synced 2025-09-22 13:42:27 +00:00
chore: working docs
This commit is contained in:
parent
295ea95d1b
commit
95400944ec
22 changed files with 158 additions and 84 deletions
|
@ -1,22 +0,0 @@
|
|||
# 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 ...
|
||||
}
|
||||
```
|
|
@ -127,6 +127,8 @@ This is fine too:
|
|||
|
||||
## Components as views
|
||||
|
||||
|
||||
<!-- md:version 0.34 -->
|
||||
_New in version 0.34_
|
||||
|
||||
Components can now be used as views. To do this, [`Component`][django_components.component.Component] subclasses Django's [`View`][] class. This means that you can use all of the [methods](https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#view) of `View` in your component. For example, you can override `get` and `post` to handle GET and POST requests, respectively.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue