Could not parse the remainder: '!='...'' from '!='...''

Request help to resolve the following issue. Pasting the Traceback,

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/table/htmx/

Django Version: 4.0.5
Python Version: 3.10.4
Installed Applications:
['app',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_tables2',
 'django_filters',
 'django_htmx',
 'crispy_forms',
 'crispy_bootstrap5',
 'Apps.Dapp.apps.DappConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django_htmx.middleware.HtmxMiddleware']


Template error:
In template D:\IT\Projects\Django\DjangoWebProject\Apps\Dapp\templates\Dapp\tables\bootstrap_htmx_full.html, error at line 75
   Could not parse the remainder: '!='...'' from '!='...''
   65 :                     <span aria-hidden="true">&laquo;</span>
   66 :                     {% trans 'previous' %}
   67 :                 </div>
   68 :             </li>
   69 :             {% endblock pagination.previous %}
   70 :             {% endif %}
   71 :             {% if table.page.has_previous or table.page.has_next %}
   72 :             {% block pagination.range %}
   73 :             {% for p in table.page|table_page_range:table.paginator %}
   74 :             <li class="page-item{% if table.page.number == p %} active{% endif %}" role="button">
   75 :                 <div class="page-link"  {% if p !='...' %}  hx-get="{% querystring table.prefixed_page_field=p %}" {% endif %} hx-trigger="click" hx-target="#table-container" hx-swap="outerHTML">
   76 :                     {{ p }}
   77 :                 </div>
   78 :             </li>
   79 :             {% endfor %}
   80 :             {% endblock pagination.range %}
   81 :             {% endif %}
   82 :             {% if table.page.has_next %}
   83 :             {% block pagination.next %}
   84 :             <li class="next page-item user-select" role="button">
   85 :                 <div hx-get="{% querystring table.prefixed_page_field=table.page.next_page_number %}" hx-trigger="click" hx-target="#table-container" hx-swap="outerHTML" class="page-link">


Traceback (most recent call last):
  File "F:\Program Files\Python310\lib\site-packages\django\template\smartif.py", line 179, in translate_token
    op = OPERATORS[token]

During handling of the above exception ("!='...'"), another exception occurred:
  File "F:\Program Files\Python310\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
  File "F:\Program Files\Python310\lib\site-packages\django\core\handlers\base.py", line 220, in _get_response
    response = response.render()
  File "F:\Program Files\Python310\lib\site-packages\django\template\response.py", line 114, in render
    self.content = self.rendered_content
  File "F:\Program Files\Python310\lib\site-packages\django\template\response.py", line 92, in rendered_content
    return template.render(context, self._request)
  File "F:\Program Files\Python310\lib\site-packages\django\template\backends\django.py", line 62, in render
    return self.template.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 175, in render
    return self._render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 167, in _render
    return self.nodelist.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 958, in render_annotated
    return self.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 167, in _render
    return self.nodelist.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 958, in render_annotated
    return self.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 167, in _render
    return self.nodelist.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 958, in render_annotated
    return self.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 167, in _render
    return self.nodelist.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 958, in render_annotated
    return self.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 958, in render_annotated
    return self.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 958, in render_annotated
    return self.render(context)
  File "F:\Program Files\Python310\lib\site-packages\django_tables2\templatetags\django_tables2.py", line 153, in render
    template = get_template(template_name)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader.py", line 15, in get_template
    return engine.get_template(template_name)
  File "F:\Program Files\Python310\lib\site-packages\django\template\backends\django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "F:\Program Files\Python310\lib\site-packages\django\template\engine.py", line 176, in get_template
    template, origin = self.find_template(template_name)
  File "F:\Program Files\Python310\lib\site-packages\django\template\engine.py", line 158, in find_template
    template = loader.get_template(name, skip=skip)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loaders\base.py", line 28, in get_template
    return Template(
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 154, in __init__
    self.nodelist = self.compile_nodelist()
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 200, in compile_nodelist
    return parser.parse()
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 232, in do_block
    nodelist = parser.parse(("endblock",))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 232, in do_block
    nodelist = parser.parse(("endblock",))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\defaulttags.py", line 954, in do_if
    nodelist = parser.parse(("elif", "else", "endif"))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\defaulttags.py", line 954, in do_if
    nodelist = parser.parse(("elif", "else", "endif"))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\loader_tags.py", line 232, in do_block
    nodelist = parser.parse(("endblock",))
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\defaulttags.py", line 854, in do_for
    nodelist_loop = parser.parse(
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 513, in parse
    raise self.error(token, e)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 511, in parse
    compiled_result = compile_func(self, token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\defaulttags.py", line 953, in do_if
    condition = TemplateIfParser(parser, bits).parse()
  File "F:\Program Files\Python310\lib\site-packages\django\template\defaulttags.py", line 886, in __init__
    super().__init__(*args, **kwargs)
  File "F:\Program Files\Python310\lib\site-packages\django\template\smartif.py", line 170, in __init__
    mapped_tokens.append(self.translate_token(token))
  File "F:\Program Files\Python310\lib\site-packages\django\template\smartif.py", line 181, in translate_token
    return self.create_var(token)
  File "F:\Program Files\Python310\lib\site-packages\django\template\defaulttags.py", line 889, in create_var
    return TemplateLiteral(self.template_parser.compile_filter(value), value)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 600, in compile_filter
    return FilterExpression(token, self)
  File "F:\Program Files\Python310\lib\site-packages\django\template\base.py", line 701, in __init__
    raise TemplateSyntaxError(

Exception Type: TemplateSyntaxError at /table/htmx/
Exception Value: Could not parse the remainder: '!='...'' from '!='...''

I think you are missing a space between the operator != and the right hand side operand '...'.
Here:

Replace this…
{% if p !='...' %}

For this:
{% if p != '...' %}

Tell me if it works!

2 Likes

Yes! Thank you so much Leandro!!

1 Like