Q&A
Django-Components의 0.128 세팅
강사님이 최신 django-components 버전을 반영한 수정본이 곧 공개될 것 같습니다. 현 시점에서 작동하는 settings.py 변경점을 기록 삼아 공유해볼게요. import sys from pathlib import Path from django_components import ComponentsSettings #변경 from environ import Env INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", #변경 "django_components", #변경 "crispy_forms", "crispy_bootstrap5", "django_extensions", "django_htmx", "template_partials", "core", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "django_htmx.middleware.HtmxMiddleware", "django_components.middleware.ComponentDependencyMiddleware", #변경 ] if DEBUG: MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", "django_components.finders.ComponentsFileSystemFinder", # 변경 ] TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [BASE_DIR / "core" / "src_django_components"], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", ], "builtins": [ "django_components.templatetags.component_tags", ], #변경 }, }, ] STATIC_ROOT = BASE_DIR / "staticfiles" #변경 # ✅ STATICFILES_DIRS 최적화 (불필요한 경로 제거) STATICFILES_DIRS = [] # 변경: 필요하면 프로젝트 공통 정적 파일 폴더만 추가 # django-components 설정 COMPONENTS = ComponentsSettings( dirs=[BASE_DIR / "core" / "src_django_components"], ) 🔥 설정 적용 후 해야 할 작업, staticfiles에 저장된 중복 파일 제거. ✅ 1⃣ 기존 정적 파일 삭제 rm -rf staticfiles/* ✅ 2⃣ 새로운 collectstatic 실행 python manage.py collectstatic --noinput ✅ 3⃣ 중복 파일 여부 확인(js, html, css ) find staticfiles -name "modal_form.js"
- Likes
- 0
- Comments
- 3
- Viewcount
- 244

