Thursday, February 2, 2012

[django-taggit] Recording additional tagging metadata with the admin

Hi, I have a question about ``django-taggit`` and the admin site.

I have written a custom intermediate model [1] for storing additional
tagging metadata, i.e. the user doing the tagging and when the tagging
happen:

class TaggedItem(GenericTaggedItemBase, TaggedItemBase):
tagger = models.ForeignKey(User, null=True, blank=True, editable=False)
tagging_time = models.DateTimeField(null=True, auto_now_add=True)

Then, I made a model taggable:

class Foo(models.Model):
# field defs

tags = TaggableManager(through=TaggedItem, blank=True)

Now when a ``Foo`` model instance is created/changed, I would like those
additional tagging metadata to be filled with ``request.user`` and the
current time.

My question is: how can I achieve this behaviour ? I suppose I have to
hook someway in the admin, but I don't know way.

Thanks in advance for any answers.


[1] http://readthedocs.org/docs/django-taggit/en/latest/custom_tagging.html

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment