Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error during template rendering / Could not parse some characters

Tags:

django

Im trying to get a bio info for each profile, when running server and going to accounts/profile y find this error:

Could not parse some characters: |% with website=profile.website| | default:"" %

{% extends 'base.html' %}

{% block title %}Profile{% endblock %}

{% block content %}

<h1>
    {{ user.get_null_name }} (@{{ user.username }})
</h1>
 
{% with profile=user.profile %}
    {% if profile %}
        <h2>
            {{ profile.persona }}  
        </h2>
        <div> 
            {{ profile.bio|default:"" }}
        </div>
        <div>
            {{ % with website=profile.website | default:"" % }}
                <a href="{{website}}">{{website}} </a>
            {% endwith %}
        </div>
        <br/>
        <div>
            Interest:
            {% for Interest in profile.interest.all %}
                <span>
                    {{ interest.name }}{% if not forloop.last %}, {% endif %}
                </span>
            {% endfor %}
        </div>
    {% endif %}
{% endwith %}


{% endblock %}
like image 862
ihincapie Avatar asked Apr 23 '26 02:04

ihincapie


1 Answers

A template tag does not use double curly brackets ({{ … }}), but single ones, with the % immediately followed by that (so {% … %}). The {% with … %} block in your template uses double curly brackets:

{% with website=profile.website|default:'' %}
    …
{% endwith %}
like image 189
Willem Van Onsem Avatar answered Apr 24 '26 23:04

Willem Van Onsem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!