개인 스터디/오류
[Django] django.template.exceptions.TemplateDoesNotExist: bootstrap4/uni_form.html 오류
you__me
2023. 3. 4. 08:33
django 스터디를 하면서 crispy를 이용해 form을 작성하려고 하면 오류가 났다.
bootstrap버전 문제인가 해서 bootstrap과 CRISPY_TEMPLATE_PACK 모두 바꿔봤는데 django.template.exceptions.TemplateDoesNotExist: bootstrap4/uni_form.html 오류가 계속 떴다..
django-crispy-forms 2.0으로 업데이트 되면서 템플릿 팩을 추가로 설치해야 한다.
pip install crispy-bootstrap4
그리고 settings.py에 'crsipy_bootstrap4' 를 작성해주면 된다.
#settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'crispy_forms',
'markdownx',
'crispy_bootstrap4',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'blog',
'single_pages',
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
{% load crispy_forms_tags %} 로 load 후
{{ form | crispy }} 가 잘 적용된다!
참고사이트
- stack overflow는 갓이당~
Django returns 'TemplateDoesNotExist' when using Crispy Forms
Using Crispy Forms with Django, I can only get a TemplateDoesNotExist error when using any feature of Crispy Forms. As I'm new to Crispy Forms (which seems to be universally recommended for quickly
stackoverflow.com