Skip to content

Commit 7f6340e

Browse files
committed
Update README
1 parent 73a90ad commit 7f6340e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,28 @@ models or forms.
202202
To render the link field in a template, use the ``LinkDict`` property ``url`` or
203203
the new template tag ``to_url``. The ``type`` property returns the link type::
204204

205-
{% load djangocms_link_tags %}
206205
{# Variant 1 #}
207206
{% if obj.link %}
208-
<a href="{{ obj.link|to_url }}">Link</a>
207+
<a href="{{ obj.link.url }}">Link available</a>
209208
{% endif %}
210209

211210
{# Variant 2 #}
211+
{% load djangocms_link_tags %}
212212
{% if obj.link %}
213-
<a href="{{ obj.link.url }}"
214-
{% if obj.link.type == "external_link" %} target="_blank"{% endif %}
215-
>Link available</a>
213+
<a href="{{ obj.link|to_url }}">Link</a>
216214
{% endif %}
217215

218216
{# Variant 3 #}
219217
{% with url=obj.link|to_url %}
220218
{% if url %}
221219
<a href="{{ url }}">Link available</a>
222220
{% endif %}
221+
{% endwith %}
222+
223+
{% if obj.link.type == "external_link" %}
224+
<a href="{{ obj.link.url }}">External link</a>
225+
{% endif %}
226+
223227

224228
To turn the ``LinkField``'s ``LinkDict`` dictionary into a URL in python code,
225229
use the ``url`` property. (It will hit the database when needed. Results are

0 commit comments

Comments
 (0)