Reputation: 321
I can't figure out what the error could be. I have checked the docs to see if there were any syntax changes but I don't find any.
Unexpected end of expression in if tag.
Template error:
In template /home/dhruv/django-blog/blog/templates/blog/post_detail.html, error at line 5
Unexpected end of expression in if tag.
1 : {% extends 'blog/base.html' %}
2 :
3 : {% block content %}
4 : <div class="post">
5 : {% if post.published_date %}
6 : <div class="date">
7 : {{ post.published_date }}
8 : </div>
9 : {% elif %}
10 : <a class="btn btn-default" href="{% url 'post_publish' pk=post.pk %}">
11 : Publish!
12 : </a>
13 : {% endif %}
14 :
15 : {% if user.is_authenticated %}
Upvotes: 3
Views: 5177
Reputation: 3248
replace:
{% elif %}
with
{% else %}
************ Doc about if/else.
if/else can be used following ways:
{% if condition %}
{% endif %}
or
{% if condition1 %}
{% elif condition2 %} # in your case, you are missing condition2
{% endif %}
or
{% if condition1 %}
{% elif condition2 %}
{% else %}
{% endif %}
or
{% if condition %}
{% else %}
{% endif %}
Upvotes: 14