📜  在模板中使用 django taggit - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:29.225000             🧑  作者: Mango

代码示例1
# models.py

from django.db import models
from taggit.managers import TaggableManager

class MyObject(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()

    tags = TaggableManager()

#template.html

{% for object in objects %}
    

{{ object.title }}

{{ object.content }}

    {% for tag in object.tags.all %}
  • {{ tag.name }}
  • {% endfor %}
{% endfor %}