regularstuff / tildeblog

A learn-to-use Django team project
BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

Make adding tags a one item operation #43

Open readytheory opened 3 months ago

readytheory commented 3 months ago

Current code (in TagHelper) when adding tags has a loop to add tags to an article, not needed, replace it with code like below

from django docs:

To add multiple records to a ManyToManyField  in one go, include multiple arguments in the call to [add()](https://docs.djangoproject.com/en/5.0/ref/models/relations/#django.db.models.fields.related.RelatedManager.add), like this:

>>> john = Author.objects.create(name="John")
>>> paul = Author.objects.create(name="Paul")
>>> george = Author.objects.create(name="George")
>>> ringo = Author.objects.create(name="Ringo")
>>> entry.authors.add(john, paul, george, ringo)