TemplateSyntaxError: widget_tweaks is not a valid library django

Question:

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

Asked By: Tom

||

Answers:

check your app settings add :

'widget_tweaks',

to your INSTALLED_APPS

Answered By: M. Gara

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

Answered By: tmd

Step 1:

pip install django-widget-tweaks

Step 2:

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

This problem will be resolved.

Answered By: Subhasish Paul

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" %}
Answered By: CodeView