61👍
Inside a {% %}
tag, variables aren’t surrounded by {{
. Try this:
{% ifequal num buildSummary_list.number %}
Also, it looks like your two comparisons can be joined with an else:
{% for num in buildSummary_list.paginator.page_range %}
{% ifequal num buildSummary_list.number %}
<b>{{num}}</b>
{% else %}
<a href="?page={{num}}"><b>{{num}}</b></a>
{% endifequal %}
{% endfor %}
19👍
I got this error when I forgot the ” around the path to a static file
This gave the error:
<link rel='stylesheet' href="{% static css/style.css %}">
This fixed the error:
<link rel='stylesheet' href="{% static 'css/style.css' %}">
- [Django]-Django: Can I create a QueryDict from a dictionary?
- [Django]-Django Rest Framework model serializer with out unique together validation
- [Django]-Django migrations RunPython not able to call model methods
1👍
The django. DjangoTemplates template backend is unable to parse a comparison operator when there is no whitespace around the operator using builtin tag if:
{% if foo=='bar' %}
<!-- do something -->
{% endif %}
raises
TemplateSyntaxError at url
Could not parse the remainder: ‘==’bar” from ‘foo==’bar”
At least one space is required on both sides of the == operator (So foo ==’bar’ and foo== ‘bar’ throws Could not parse the remainder: ‘==’bar” from ‘==’bar” and Could not parse the remainder: ‘==’ from ‘foo==’, respectively). More than one space is acceptable.
This seems to affect the following boolean operators: ==, !=, <, >, <=, >=. My guess is the boolean expression tokenizer in DjangoTemplates first tries split(‘ ‘) then ultimately evals [0][1][2] (but I haven’t actually looked at the source to verify this).
- [Django]-OSError: [Errno 18] Invalid cross-device link
- [Django]-Django Rest Framework — no module named rest_framework
- [Django]-Find all references to an object in python
1👍
thats so easy you should not write like this
{% if foo=='bar' %}
<!-- do something -->
{% endif %}
you should write your code like this
{% if foo == 'bar' %}
<!-- do something -->
{% endif %}
pay attention to the space before ==
- [Django]-Django, ModelChoiceField() and initial value
- [Django]-Check for pending Django migrations
- [Django]-Python MySQLDB: Get the result of fetchall in a list
1👍
When you are dealing with comparison operator ==
within templates, make sure you have spaces before and after ==
operator. This could be one of the reason for above error.
For ex. category.slug == c.slug
- [Django]-How do I add a "class" to a ChoiceField in Django?
- [Django]-Django redirect after login not working "next" not posting?
- [Django]-What are the best practices to use AngularJS with Django
0👍
django 2.2 relative URL
**Correct**
<a href="{% url 'urlapp:other' %}">go to other page </a>
<br/>
<a href="{% url 'admin:index' %}"> admin page</a>
**error inccorect code some white space still get same error **
<a href="{% url 'urlapp:other' %}">go to other page </a>
<br/>
<a href="{% url 'urlapp: other' %}">go to other page </a>
<br/>
<a href="{% url 'admin:index' %}"> admin page</a>
<br/>
<a href="{% url 'admin':index %}"> admin page</a>
- [Django]-How to allow users to change their own passwords in Django?
- [Django]-URL encoding on Django Template
- [Django]-How can I upgrade specific packages using pip and a requirements file?
0👍
Could not parse the remainder: ‘>0’ from ‘forloop.counter>0’
I got this error !!!
if its a TemplateSyntaxError then just correct your spaces between the code
For example:
( wrong statement ) {% if forloop.counter|divisibleby:3 and forloop.counter>0 and not forloop.last %}
( right statement ) {% if forloop.counter|divisibleby:3 and forloop.counter > 0 and not forloop.last %}
space between ( forloop.counter > 0)
this worked for me
- [Django]-How do I restart celery workers gracefully?
- [Django]-Collectstatic error while deploying Django app to Heroku
- [Django]-Warning: cannot find svn location for distribute==0.6.16dev-r0