You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{% for comment in comment_list|fill_tree|annotate_tree %}
{% ifchanged comment.parent_id %}{% else %}</li>{% endifchanged %}
{% if not comment.open and not comment.close %}</li>{% endif %}
{% if comment.open %}<ul>{% endif %}
<li id="c{{ comment.id }}">
...
{% for close in comment.close %}</li></ul>{% endfor %}
{% endfor %}
The 2nd line may have some faults.
If the comment.parent_id remains None, the ifchanged condition is False,
and it will output an </li>.
But if the comment is the root comment, that is, the comment is not a reply to an existing comment,
its parent_id is None.
Hence, there may be unnecessary </li> between the root comments.
As the browser is smart enough, it will removed the unmatched </li>,
so we may not be aware of this kind of bug.
However, if we use <div><div> instead of <ul><li>,
then the unnecessary </div> will mismatch other <div>.
So, I think the solution is to double check the comment.parent_id:
Here are the codes in your instrcution:
The 2nd line may have some faults.
If the
comment.parent_id
remainsNone
, theifchanged
condition isFalse
,and it will output an
</li>
.But if the comment is the root comment, that is, the comment is not a reply to an existing comment,
its parent_id is
None
.Hence, there may be unnecessary
</li>
between the root comments.As the browser is smart enough, it will removed the unmatched
</li>
,so we may not be aware of this kind of bug.
However, if we use
<div><div>
instead of<ul><li>
,then the unnecessary
</div>
will mismatch other<div>
.So, I think the solution is to double check the
comment.parent_id
:The text was updated successfully, but these errors were encountered: