Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newbie question about paths/views #172

Open
macumhail opened this issue Nov 2, 2022 · 0 comments
Open

Newbie question about paths/views #172

macumhail opened this issue Nov 2, 2022 · 0 comments
Milestone

Comments

@macumhail
Copy link

macumhail commented Nov 2, 2022

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>
@radiac radiac added this to the 1.4.0 milestone Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready
Development

No branches or pull requests

2 participants