pythondjangodjango-templatesdjango-crispy-forms

Django crispy-forms TemplateDoesNotExist


I am new in Django, so I was trying structures in the book "Django for Beginners by William S Wincent" about how to attach crispy forms to my signup page!

However, in the middle of my progress in the topic, I faced to TemplateDoesNotExist exception! Error: Error description

Here is where the error raises: Error description

And here is my settings.py configuration:

...

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'crispy_forms',
    "accounts",
    "pages",
]
CRISPY_TEMPLATE_PACK = "bootstrap4"
...

django = 4.2.3 django-crispy-forms = 2.0

I've tried to create a Sign Up Page, configuring its views and urls properly to host crispy_forms in my project.

Also crispy_forms(Version 2.0) is installed. Packages installed in my virtual environment


Solution

  • You need to add 'crispy_bootstrap4' to the INSTALLED_APPS as well:

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'crispy_forms',
        'crispy_bootstrap4',  # 🖘 add crispy_bootstrap4
        'accounts',
        'pages',
    ]

    If you use bootstrap-4 templates, you need to load the app that exposes these templates for the render engine.