0

I am working on django project. When I run server on windows using python 3.5 it is working fine for me. But on Linux, using python 2.5 it is not working. it is giving following error:

TemplateSyntaxError at /tableapp/index/

'verbose_names' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
static
staticfiles
tz
widget_tweaks

verbose_names.py is defined in folder tableapp/templatetags/

from django import template
from django.template.defaultfilters import stringfilter

register = template.Library()


@register.simple_tag
def get_verbose_field_name(instance, field_name):
    """
    Returns verbose_name for a field.
    """
    return instance._meta.get_field(field_name).verbose_name.title()


@register.simple_tag
@stringfilter
def trim(value):
    return value.lower().strip()


@register.filter
def get_item(dictionary, key):
    return dictionary.get(key)

Template (configuration.html) renders at /tableapp/index/ :

{% extends 'base.html' %}
{% load verbose_names %}

{% block extra_css %}

 <style>
 /*Tags not selected class*/
.span1 {
  background-color: #ADD8E6;
  border: none;
  border-radius: 12px;
  color: white;
  padding: 10px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 13px;
  margin: 1px 1px;
}

/*Setting Width for tagsBox*/
.bootstrap-tagsinput {
  /*width: 70% !important;*/
  width: 420px !important;
}

/*Avoid text box*/
.bootstrap-tagsinput {
 border: none;
 box-shadow: none;
}

.bootstrap-tagsinput input {
   display: none;
}

/*Tags Selected Class*/
.myclass {
  background-color: #3090C7;
  border: none;
  border-radius: 12px;
  color: white;
  padding: 10px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 13px;
  margin: 1px 1px;
}
</style>
{% endblock %}

I have googled below link for the issue, followed all the answers but none of it worked, I don't know the issue yet.

Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of:

scharette
  • 9,437
  • 8
  • 33
  • 67
Rohit Mandhan
  • 89
  • 2
  • 13

1 Answers1

0

By convention the template tag should be like your_app/templatetags/ and it will contain two file one is init.py and another is your template tag file suppose my_tag.py Then you have to load it in template {% load my_tag %}

Sam
  • 815
  • 10
  • 23