use django taggit in template

Solutions on MaxInterview for use django taggit in template by the best coders in the world

showing results for - "use django taggit in template"
Maximilian
22 Feb 2017
1# models.py
2
3from django.db import models
4from taggit.managers import TaggableManager
5
6class MyObject(models.Model):
7    title = models.CharField(max_length=100)
8    content = models.TextField()
9
10    tags = TaggableManager()
11
12#template.html
13
14{% for object in objects %}
15    <h2>{{ object.title }}</h2>
16    <p>{{ object.content }}</p>
17    <ul>
18        {% for tag in object.tags.all %}
19            <li> {{ tag.name }} </li>
20        {% endfor %}
21    </ul>
22{% endfor %}
23