5

I am new to django and I am trying to trying to implement a form that uses widget-tweaks.

I did install widget tweaks (I am using Ubuntu 14.04)

sudo pip install django-widget-tweaks

My settings file looks like this:

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
'addattr',
'widget_tweaks',
)

The html looks like this:

{% extends "base/theme.html" %}
{% load widget_tweaks %}
{% block main_content %}
...more code...

The class in the views and the linking in the url works perfectly fine.

But every time when I try to load the html it says:

widget_tweaks' is not a valid tag library: Template library widget_tweaks not found, tried django.templatetags.widget_tweaks,django.contrib.admin.templatetags.widget_tweaks,django.contrib.staticfiles.templatetags.widget_tweaks

Can anyone help? Thanks in advance

Tom
  • 2,545
  • 5
  • 31
  • 71
  • Sounds like `widget_tweaks` isn't on the PYTHONPATH. If you're not already, my recommendation would be to use virtualenv and virtualenvwrapper to install modules via pip. https://virtualenvwrapper.readthedocs.org/en/latest/ – Brandon Taylor May 24 '15 at 17:10

4 Answers4

6

check your app settings add :

'widget_tweaks',

to your INSTALLED_APPS

M. Gara
  • 1,023
  • 2
  • 14
  • 27
4

ubuntu use pip3

step 1:


convert
sudo pip install django-widget-tweaks

to:

sudo pip3 install django-widget-tweaks

step 2:


add name lib in settings.py

you can use :

INSTALLED_APPS+=['widget-tweaks']

or inside

INSTALLED_APPS

step 3:


in templates use:
{% load widget_tweaks %}

test:

in templates

{% load widget_tweaks %}
<!-- change input type (e.g. to HTML5) -->
{% render_field form.search_query type="search" %}
Tom
  • 2,545
  • 5
  • 31
  • 71
CodeView
  • 498
  • 3
  • 14
  • 1
    I get **ModuleNotFoundError: No module named 'widget-tweaks'**. I have installed django-widget-tweaks – AnonymousUser Jul 25 '22 at 04:26
  • So I had to add it under the apps. I guess that's why the pypi documentations says to add it like this `INSTALLED_APPS += [ 'widget_tweaks', ]` https://pypi.org/project/django-widget-tweaks/ – AnonymousUser Jul 25 '22 at 04:31
1

you installed the widget_tweaks as super admin and maybe you were using a virtualenv just do pip install django-widget-tweaks

Titus Dishon
  • 96
  • 2
  • 5
1

Step 1:

pip install django-widget-tweaks

Step 2:

In settings.py, add 'widget_tweaks', under INSTALLED_APPS

This problem will be resolved.

Grayrigel
  • 3,474
  • 5
  • 14
  • 32