Skip to content

Commit a72e876

Browse files
authored
Added django-components library and config. (#585)
1 parent a5a46b5 commit a72e876

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

djangosnippets/settings/base.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from pathlib import Path
23

34
import dj_database_url
45
from django.contrib import messages
@@ -13,6 +14,7 @@ def user_url(user):
1314

1415

1516
PROJECT_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
17+
BASE_DIR = Path(__file__).resolve().parent.parent.parent
1618

1719
SITE_ID = 1
1820
SITE_NAME = "djangosnippets.org"
@@ -68,6 +70,7 @@ def user_url(user):
6870
"theme",
6971
"django_recaptcha",
7072
"django_extensions",
73+
"django_components",
7174
"rest_framework",
7275
"django_htmx",
7376
)
@@ -92,7 +95,6 @@ def user_url(user):
9295
{
9396
"BACKEND": "django.template.backends.django.DjangoTemplates",
9497
"DIRS": [os.path.join(PROJECT_ROOT, "templates")],
95-
"APP_DIRS": True,
9698
"OPTIONS": {
9799
"context_processors": [
98100
"django.contrib.auth.context_processors.auth",
@@ -102,13 +104,29 @@ def user_url(user):
102104
"django.contrib.messages.context_processors.messages",
103105
"django.template.context_processors.request",
104106
],
107+
"loaders": [(
108+
"django.template.loaders.cached.Loader", [
109+
"django.template.loaders.filesystem.Loader",
110+
"django.template.loaders.app_directories.Loader",
111+
"django_components.template_loader.Loader",
112+
]
113+
)],
114+
'builtins': [
115+
'django_components.templatetags.component_tags',
116+
],
105117
},
106118
}
107119
]
108120

109121
STATIC_URL = "/assets/static/"
110122
STATIC_ROOT = os.path.join(PROJECT_ROOT, "..", "assets", "static")
111123
STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, "static"),)
124+
STATICFILES_FINDERS = [
125+
"django.contrib.staticfiles.finders.FileSystemFinder",
126+
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
127+
"django_components.finders.ComponentsFileSystemFinder",
128+
]
129+
112130
TAILWIND_APP_NAME = "theme"
113131

114132
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"

djangosnippets/settings/development.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
CACHE_BACKEND = "dummy://"
1010

1111
INSTALLED_APPS = INSTALLED_APPS
12+
13+
TEMPLATES[0]["OPTIONS"]["loaders"] = [
14+
"django.template.loaders.filesystem.Loader",
15+
"django.template.loaders.app_directories.Loader",
16+
"django_components.template_loader.Loader",
17+
]

requirements/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ whitenoise==6.1.0
2323
psycopg2-binary==2.9.10
2424
djangorestframework==3.14.0
2525
django-htmx==1.15.0
26+
django_components==0.141.1
2627
gevent==22.10.2 # Updated version of gevent
2728
greenlet==3.0.3 # Updated version of greenlet
2829
requests-oauthlib==1.3.1

0 commit comments

Comments
 (0)