Skip to content

Instantly share code, notes, and snippets.

@rwoloszyn
Created August 9, 2018 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwoloszyn/9fa279b77a9aa7fbc908cb56caccc900 to your computer and use it in GitHub Desktop.
Save rwoloszyn/9fa279b77a9aa7fbc908cb56caccc900 to your computer and use it in GitHub Desktop.
Django get element from m2m relation in django template
{% with object.group_set.all|first as group %}
<li class="breadcrumb-item"><a href="{% url 'group_detail' group_id=view.kwargs.group_id %}">{{ group.name }}</a></li>
{% endwith %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment