Skip to content

Commit 90172da

Browse files
committed
Merge branch 'main' of github.com:rails-inspire-django/django-view-component
2 parents bbda88f + ce35059 commit 90172da

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/source/preview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ Add below config to your Django settings
99
```python
1010
VIEW_COMPONENTS = {
1111
"preview_base": ["django_app/tests/previews"],
12+
"show_previews": DEBUG,
1213
}
1314
```
1415

15-
`preview_base` is the base path for your previews. You can add multiple paths to it.
16+
1. `preview_base` is the base path for your previews. You can add multiple paths to it.
17+
2. `show_previews` is a boolean value, which is used to control whether to show the previews. It is `True` by default, here we set it with same value of `DEBUG`. So the previews will only be shown in the development environment.
1618

1719
Add below url path to your Django urls
1820

src/django_viewcomponent/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from django.template.engine import Engine
88
from django_viewcomponent.loaders import ComponentLoader
9-
from django_viewcomponent.app_settings import app_settings
109

1110

1211
def autodiscover_components():
@@ -20,6 +19,8 @@ def autodiscover_components():
2019

2120

2221
def autodiscover_previews():
22+
from django_viewcomponent.app_settings import app_settings
23+
2324
if app_settings.SHOW_PREVIEWS:
2425
preview_base_ls = [Path(p) for p in app_settings.PREVIEW_BASE]
2526
for directory in preview_base_ls:

0 commit comments

Comments
 (0)