1

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

Brian Destura
  • 11,487
  • 3
  • 18
  • 34
patel887
  • 167
  • 1
  • 11

4 Answers4

2

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
patel887
  • 167
  • 1
  • 11
2
pip install crispy-bootstrap5

this worked for me

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 19 '21 at 07:20
0

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

VirtualScooter
  • 1,792
  • 3
  • 18
  • 28
0

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