11

I am trying to customize my Django forms using widget tweaks for an app I'm building with a group and I keep getting an error:

ModuleNotFoundError: No module named 'widget_tweaks'

I don't understand why.

I installed the module on my mac with $ pip install django-widget-tweaks and placed 'widget_tweaks' in the INSTALLED_APPS = [...] part of my app's settings.py file. Those were the only 2 things I saw that I needed to do after reading the documentation for how to use widget tweaks.

settings.py file snippet:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'PupsToPet.apps.PupstopetConfig',
    'widget_tweaks',
   #'django.contrib.easy_maps',
]
Thao
  • 111
  • 1
  • 1
  • 4

5 Answers5

27

Try to install with pip3:

pip3 install django-widget-tweaks 
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
nevermore
  • 271
  • 2
  • 3
5

I had this same problem and it was killing me!

(for me) The problem was that I was working in an virtural env in PyCharm) but I have a global python as well. From my command line I was running manage.py runserver, the problem being that my global python doesn't have the widget-tweaks library installed. ( I didn't realize I wasn't running from the venv)

If you're like me the solution is make sure you're in the right environment,

from PyCharm I did tools -> run manage.py task -> runserver

and it worked...

Reed Jones
  • 1,367
  • 15
  • 26
0

Ahh this is working for me look when write python -m pip install Pillow this problem solved for me

0

My problem was resolved after upgrading my pip version from 21.0.1 to 21.1.1 using pip install --upgrade pip

Yeboah
  • 1
0

I got this since I added 'widget_tweaks', above the started apps. You need to add it under the started apps, you can add pip installed like this INSTALLED_APPS += [ 'widget_tweaks', ] under INSTALLED_APPS. Only add pip installed apps in INSTALLED_APPS += [] and started apps in INSTALLED_APPS = [].

Or you can just add the pip installed apps bellow the started apps. Like this:

Settings.py only showing INSTALLED_APPS

...
INSTALLED_APPS = [ 
    
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'PupsToPet.apps.PupstopetConfig',
    ...
     
    # Started apps first
    'app1',
    'app2',
    ...

    # pip installed at the bottom
    'widget_tweaks',
    ...
    
]
...
AnonymousUser
  • 690
  • 7
  • 26