Don't rely on existence of BASE_DIR settings variable.

This commit is contained in:
Fabian Binz 2024-12-06 12:22:51 +01:00
parent bd96c0089f
commit 6b876a6f3f
4 changed files with 28 additions and 5 deletions

View file

@ -13,6 +13,17 @@
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
<div>
<code>COTTON_BASE_DIR</code>
<div>str (default: None)</div>
</div>
<div>
The base directory where - in addition to the app folders - cotton will search for the "templates" directory (see above).
If not set, the `BASE_DIR` generated by `django-admin startproject` is used as a fallback, if it exists.
</div>
</div>
<c-hr />
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
@ -42,4 +53,4 @@
</div>
</c-layouts.with-sidebar>
</c-layouts.with-sidebar>

View file

@ -81,7 +81,10 @@ TEMPLATES = [
<c-ul>
<li><strong>App level</strong> - You can place your cotton folder in any of your installed app folders, like: <div><code>[project]/[app]/templates/cotton/row.html</code></div></li>
<li><strong>Project root</strong> - You can place your cotton folder in a project level templates directory, like: <div><code>[project]/templates/cotton/row.html</code></div></li>
<li>
<strong>Project root</strong> - You can place your cotton folder in a project level templates directory, like: <div><code>[project]/templates/cotton/row.html</code></div>
(where the <code>[project]</code> depends on the `BASE_DIR` or `COTTON_BASE_DIR` settings)
</li>
</c-ul>
<p>Any style will allow you to include your component the same way: <code>{{ '<c-row />'|force_escape }}</code></p>