Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'crispy_forms' #1385

Open
leondhallam opened this issue Mar 26, 2024 · 2 comments
Open

ModuleNotFoundError: No module named 'crispy_forms' #1385

leondhallam opened this issue Mar 26, 2024 · 2 comments

Comments

@leondhallam
Copy link

leondhallam commented Mar 26, 2024

  • Django version: 5.0.3
  • Python version: 3.11.8
  • Template pack: (Optional)

Description:

I am trying to use Django Crispy Forms in order to change the appearance of the form I've built as part of an assignment. Issue is when I follow the instructions given to me to be able to enable crispy forms I always get the "No module named 'crispy_forms'" error and can't find a fix for it.
My assignment requires me to use crispy forms so I have no idea what to do as I've spent hours trying to troubleshoot the problem and nothing works.

settings.py:

from pathlib import Path

BASE_DIR = Path(file).resolve().parent.parent

SECRET_KEY = 'REDACTED'

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'itreporting.apps.ItreportingConfig',
'users.apps.UsersConfig',
'crispy_forms',
'crispy_bootstrap4',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'itapps.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'itapps.wsgi.application'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True

STATIC_URL = 'static/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGIN_REDIRECT_URL = 'itreporting:home'

CRISPY_ALLOWED_TEMPLATE_PACK = 'bootstrap4'

CRISPY_TEMPLATE_PACK = 'bootstrap4'
`

If anyone can help me fix this it would be greatly appreciated as I'm considering pretending to be a cat and seeing if I can land on my legs after jumping out my 3rd story window.

@smithdc1
Copy link
Member

Hi @leondhallam this is usually a virtual environment issue.

If you do a pip list before you launch django's runserver, do you see django-crispy-forms listed?

@leondhallam
Copy link
Author

Just re-installed it to try again and yeah crispy does appear from pip list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants