Django ModuleNotFoundError: No module named 'crispy_bootstrap5'

7.6k Views Asked by At

I am trying to import crispy_bootstrap5. I have activated my virtual environment after that I have update my requirements.txt in which it is installing crispy_bootstrap5 but getting error ModuleNotFoundError: No module named 'crispy_bootstrap5'

enter image description here

I have also try to install it with pip but it is giving that it is already installed.

Using Pycharm terminal

This is my part of my settings.py:

INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'polls',
        'crispy_bootstrap5',
    )
CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap5'
CRISPY_TEMPLATE_PACK = 'bootstrap5'

Any help will be appreciated

4

There are 4 best solutions below

0
patel887 On BEST ANSWER

I was using docker to run my project with django container. so for that I had to follow this step to make it work.

docker ps

docker exec -it <docker_id_for_django_container> /bin/bash or docker exec -it <docker_id_for_django_container> /bin/sh

pip install -r requirements.txt
1
Yosvany Pizarroza On

Need to add crispy_forms into installed_apps:

INSTALLED_APPS = (
    ...
    "crispy_forms",
    "crispy_bootstrap5",
    ...
)

CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"

CRISPY_TEMPLATE_PACK = "bootstrap5"

Read the oficial documentation: https://github.com/django-crispy-forms/crispy-bootstrap5

1
Jestin M Wilson On
pip install crispy-bootstrap5

this worked for me

0
Abhishek Yadav On

I am working with Docker and this worked for me:

docker-compose exec web pip install crispy_bootstrap5

Also would like to mention if you are following Django For Professionals refer this : https://github.com/wsvincent/djangoforprofessionals