I have this field on a Django template:
<p class="border_dotted_bottom">
{{ expert.description|slice:":300" }}
<a href="{% url 'profile' expert.username %}">{% trans "read more" %}</a>....
</p>
If this object (user) has no 'decription' (a text field) it shows the word 'None', I need to get rid of that, maybe if he doesn't have a 'description' then show a Simple text and then "read more"
So far, I've tried this:
<p class="border_dotted_bottom">
{{ % if expert.description >= 1 %}}
{{ expert.description|slice:":300" }}
{{% else %}}
Éste usuario por el momento no tiene descripción
<a href="{% url 'profile' expert.username %}">{% trans "read more" %}</a>....
</p>
But it doesn't work, I think it's just a typo, or maybe something to do with the conditional I'm using here...
Anybody can shed some light on this?
Thanks in advance!
Your problem is with your
if/elsetags. You have this:First off, you need to surround
if/elseby{% %}, not{{% %}}. Secondly, you don't have anendif. Anif/elseblock should look like this:Therefore, your desired block would look something like this:
That being said, you should be able to simplify this using Django's built-in
defaulttag ordefault_if_nonetag, depending on whether you want to give a default ifexpert.descriptionis equal to''/Noneor onlyNone: