Django returns 'TemplateDoesNotExist' when using Crispy Forms
Published May 14, 2024, 5:44 a.m. by tonu11singh@gmail.com
Using Crispy Forms with Django, I can only get a TemplateDoesNotExist error when using any feature of Crispy Forms. if you need to use bootstrap4
pip install django-crispy-forms pip install crispy-bootstrap4
Inside settings.py in the main app add INSTALLED_APPS = [ ... 'crispy_forms', 'crispy_bootstrap4', ... ] and CRISPY_TEMPLATE_PACK = 'bootstrap4' inside your_html.html file add {% load crispy_forms_tags %} and you can use cripy_forms as you like Run this command: pip install django-crispy-forms Go to settings.py and add this in the installed apps (don't forget the comma): "crispy_forms", "crispy_bootstrap4"
Add this after the installed apps (here there's no need for a comma):
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap4"
CRISPY_TEMPLATE_PACK = 'bootstrap4'
Go to the html page where you want to add the crispy form and add this in the head section:
{% load crispy_forms_tags %}
Finally add this to the body section:
{{form|crispy_field}}
Similar posts
There are no similar posts yet.0 comments
There are no comments.