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

Add support for initialising tags via a list on object creation #864

Open
waveywhite opened this issue Jul 25, 2023 · 1 comment
Open

Add support for initialising tags via a list on object creation #864

waveywhite opened this issue Jul 25, 2023 · 1 comment

Comments

@waveywhite
Copy link

It should be possible to initialise tags via a list

class` MyModel(models.Model):
    tags=TaggableManager()

ob = MyModel(tags=['tag1', 'tag2'])
ob.save()

assert( len( MyModel.objects.filter[tags__name__in=['tag1'] ) ) == 1 )
@rtpg
Copy link
Contributor

rtpg commented Sep 20, 2023

I totally understand wanting this, but basically taggit is following how M2M models work in Django in general. This involves needing to save the "owning" model first (to have an id to be associated to), and generally all the APIs treat this stuff as "you save it immediately", because doing otherwise leads to weird confusing code. Hence stuff like .set.

I haven't seen any other library venture into this territory, so am afraid to do so myself. If anyone has seen another library in the wild handle many-to-many relationships in this way, please share links here! It could provide good information on how to deal with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants