radiac/django-tagulous

Newbie question about paths/views

macumhail opened this issue · 0 comments

I created an app for site wide tags. I can add the tags to other models via forms and display the tags associated with instances of other models. I am not sure how to make the tags clickable and once clicked display a list of items tagged with that specific tag. Is the path/url and view auto-created?

My tag model:

class SiteWideTags(tagulous.models.TagModel):
    class TagMeta:
        # Tag options
        force_lowercase = True

An example model with a SiteWideTags field:

class Document(models.Model):
    title = models.CharField(max_length= 200)
    description = models.TextField()
    date = models.DateTimeField(auto_now_add=True, null=True)
    created_by = models.ForeignKey(CustomUser, editable=False, null=True, blank=True, on_delete=models.RESTRICT)
    file = ConstrainedFileField(
                            null=True,
                            blank=True,
                            upload_to='documents/%m%Y',
                            content_types=['application/pdf', 'image/png', 'image/jpg', 'image/jpeg', 'image/gif'],
                            max_upload_size=2097152,
                                    )
    tags = tagulous.models.TagField(to=SiteWideTags)

Relevant template code:

<p>tags:<a href="{{ tags }}">{{ document.tags }}</a></p>