[Django]-Django: TemplateSyntaxError: Could not parse the remainder

143๐Ÿ‘

โœ…

This error usually means youโ€™ve forgotten a closing quote somewhere in the template youโ€™re trying to render. For example: {% url 'my_view %} (wrong) instead of {% url 'my_view' %} (correct). In this case itโ€™s the colon thatโ€™s causing the problem. Normally youโ€™d edit the template to use the correct {% url %} syntax.

But thereโ€™s no reason why the django admin site would throw this, since it would know itโ€™s own syntax. My best guess is therefore that grapelli is causing your problem since it changes the admin templates. Does removing grappelli from installed apps help?

๐Ÿ‘คGarry Cairns

12๐Ÿ‘

For me it was using {{ }} instead of {% %}:

href="{{ static 'bootstrap.min.css' }}"  # wrong
href="{% static 'bootstrap.min.css' %}"  # right
๐Ÿ‘คReemRashwan

5๐Ÿ‘

There should not be a space after name.

Incorrect:

{% url 'author' name = p.article_author.name.username %}

Correct:

{% url 'author' name=p.article_author.name.username %}
๐Ÿ‘คuser13493827

2๐Ÿ‘

Template Syntax Error: is due to many reasons one of them is {{ post.date_posted|date: โ€œF d, Yโ€ }} is the space between colon(:) and quote (โ€œ) if u remove the space then it work like this โ€ฆ.. {{ post.date_posted|date:โ€F d, Yโ€ }}

๐Ÿ‘คZiar Khan

2๐Ÿ‘

In templates/admin/includes_grappelli/header.html, line 12, you forgot to put admin:password_change between '.

The url Django tag syntax should always be like:

{% url 'your_url_name' %}
๐Ÿ‘คTms91

1๐Ÿ‘

also happens when you use jinja templates (which have different syntax for calling object methods) and you forget to set it in settings.py

๐Ÿ‘คMichel Samia

1๐Ÿ‘

You have indented part of your code in settings.py:

# Uncomment the next line to enable the admin:
     'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    #'django.contrib.admindocs',
     'tinymce',
     'sorl.thumbnail',
     'south',
     'django_facebook',
     'djcelery',
     'devserver',
     'main',

Therefore, it is giving you an error.

๐Ÿ‘คadvaiyalad

1๐Ÿ‘

for me, when I checked if condition:
This made error:

{%if number==10 %}

This solved error:

{% if number == 10 %}  #you may notice about space!
๐Ÿ‘คDe Zin Htang

0๐Ÿ‘

Make sure you are using static files and URLs properly

<link href="{% static 'css/semantic.min.css' %}" rel="stylesheet">
  • Check it is properly surrounded with quotation marks or not
  • Check beginning and ending brackets
  • Check tag is closed properly or not
๐Ÿ‘คMD SHAYON

0๐Ÿ‘

I got the same error below:

django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: โ€˜:testโ€™ from โ€˜my_app1:testโ€™

Because I didnโ€™t use quotes for my_app1:test with url tag as shown below. *Since Django 1.5, quotes have been needed:

<a href="{% url my_app1:test %}">Test</a>
            {% โ†‘ No quotes  โ†‘ %}

So, I used quotes for my_app1:test with url tag as shown below, then the error was solved:

<a href="{% url 'my_app1:test' %}">Test</a>
             {% โ†‘   quotes   โ†‘ %}

Leave a comment