You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes! So like you said, what you need to do is something like Tag.objects.create(...) to first create the tags (this is if you are using the base Tag model). So you can just do from taggit.models import Tag and go from there.
Now the rest is a bit manual but here's an idea for how I would do this from scratch. Here I'm assuming you add tags to a Post model, via post.tags.
In the code that creates Posts, write a validation that checks that the provided tags all already exist (Tag.objects.filter(name__in=tag_list) == len(tag_list), if users are passing in a tag list as strings). If the length is mismatched, that means that in the tag list there is a tag that doesn't exist already
Create an admin page for Tags or the like so that you can create tags. Alternatively, programmatically create tags inside of a data migration
You can also create a special Tag subclass with some extra validation to ensure that the tag name is correct. What makes sense depends on what you are doing, really.
Hi,
is there a way to create indepentend tags like:
Tag.objects.create(name="Tag name", slug="tag-name")
Reason:
In my use case are allowed to create tags an users can use the pre-defined tags. So users should not be allowed to create new ones.
The text was updated successfully, but these errors were encountered: