django-crispy-forms / crispy-bootstrap4

Bootstrap 4 template pack for django-crispy-forms
MIT License
11 stars 5 forks source link

ModuleNotFoundError: No module named 'crispy_bootstrap4' #18

Closed Minras closed 1 year ago

Minras commented 1 year ago

When adding "crispy_bootstrap4", to INSTALLED_APPS, Django fails with the following error:

ModuleNotFoundError: No module named 'crispy_bootstrap4'

To localize the problem, I tried to create a new project and add only crispy forms there, and the problem still exists. Environment:

asgiref==3.7.2
crispy-bootstrap4==2022.1
Django==4.2.3
django-crispy-forms==2.0
sqlparse==0.4.4

Python version: 3.11.3

lmponcio commented 1 year ago

Hi @Minras. I am trying crispy forms for the first time, and I found this issue.

I just made it work for a simple form for comments in a blog so I will leave down here what I did in case useful:

My env has, amongst other stuff, the same packages installed as yours

Django==4.2.2
crispy-bootstrap4==2022.1
django-crispy-forms==2.0

My python version is Python 3.11.4

in settings.py (or base.py) I got:

INSTALLED_APPS = [
    # all my other apps up here...
    "crispy_forms",
    "crispy_bootstrap4",
]

# more settings in the middle here...

CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap4"

CRISPY_TEMPLATE_PACK = "bootstrap4"

and in my template I got:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
{% load crispy_forms_tags %}

<!-- more code in the middle.. -->

<h4 class="card-title card-title-dash mb-4">Add a comment</h4>
<form method="POST">
    {% csrf_token %}
    <div class="form-group">
        {{comment_form|crispy}}
        <button type="submit" class="btn btn-success">Add comment <i class="fas fa-comments"></i></button>
    </div>
</form>

Again, not an expert here, but I hope this comment is useful in some way

Regards!

smithdc1 commented 1 year ago

Please have a look at https://github.com/django-crispy-forms/django-crispy-forms/issues/377. In particular this comment.

This seems to me like a project config issue rather than an issue with crispy_bootstrap4 as such. Happy to accept PRs to improve clarity to docs if that would help.