0
votes

I have this error : django.template.base.TemplateSyntaxError: 'block' tag with name 'bottom_js' appears more than once

But I have no clue which template is at fault, how do I find this out ?

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/core/management/base.py", line 217, in execute
    translation.activate('en-us')
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 105, in activate
    return _trans.activate(language)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 194, in activate
    _active.value = translation(language)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 183, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 160, in _fetch
    app = import_module(appname)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/dbgettext/__init__.py", line 42, in <module>
    autodiscover()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/dbgettext/__init__.py", line 24, in autodiscover
    app_path = import_module(app).__path__
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/haystack/__init__.py", line 154, in <module>
    handle_registrations()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/haystack/__init__.py", line 151, in handle_registrations
    search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/maazza/PycharmProjects/list_app/list_app/search_sites.py", line 2, in <module>
    from cms.models import monkeypatch_reverse
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/cms/__init__.py", line 9, in <module>
    patch_settings()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/cms/conf/__init__.py", line 39, in patch_settings
    post_patch_check()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/cms/conf/patch.py", line 56, in post_patch_check
    if not validate_template(template[0], ['js', 'css']):
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/sekizai/helpers.py", line 97, in validate_template
    found = get_namespaces(template)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/sekizai/helpers.py", line 87, in get_namespaces
    compiled_template = get_template(template)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template
    template, origin = find_template(template_name)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader.py", line 134, in find_template
    source, display_name = loader(name, dirs)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader.py", line 42, in __call__
    return self.load_template(template_name, template_dirs)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader.py", line 48, in load_template
    template = get_template_from_string(source, origin, template_name)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader.py", line 156, in get_template_from_string
    return Template(source, origin, name)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/base.py", line 125, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/base.py", line 153, in compile_string
    return parser.parse()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/base.py", line 267, in parse
    compiled_result = compile_func(self, token)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 214, in do_extends
    nodelist = parser.parse()
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/base.py", line 267, in parse
    compiled_result = compile_func(self, token)
  File "/home/maazza/.virtualenvs/list_app/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 185, in do_block
    raise TemplateSyntaxError("'%s' tag with name '%s' appears more than once" % (bits[0], block_name))
django.template.base.TemplateSyntaxError: 'block' tag with name 'bottom_js' appears more than once

EDIT: In a template I found this :

{% render_block "bottom_js" %}
{% block bottom_js %}
    <script>
     stufff
    </script>
{% endblock %}

Does it make a duplicate of the bottom_js block ?

1
Do you have Debug=True in your settings.py? You should get a stacktrace.Henrik Andersson
I have the stacktrace but it does not mention the template namemaazza
It should post where it originates from. Could you post it, please?Henrik Andersson
Yes, that produces two blocks. It's from Sekizai. If you want to add to that block use the tags {% addtoblock "bottom_js" %} {% endaddtoblock %}.Henrik Andersson
ok , but it seems i need to check all the templates for it , damnmaazza

1 Answers

2
votes

Ok fixed using a search in Pycharm and spotting 2 usages in the same File. I hope there is way to find it out without PyCharm tough.

grep equivalent:

 grep -r -i "bottom_js" ./

taken from here : http://www.tonyspencer.com/2005/10/14/grep-all-files-and-sub-directories-in-a-directory-for-a-string/