Hi,
So, I have the 4 entities represented below which are strong
and independent entities on my application, now the problem is that each
Article or Picture could be "tagged" with a Presenter or an Event,
being as they are the 4 of them independent entities that could become
more complex It doesn't look right to add Event and Presenter field to
both Article and Picture or the contrary, specially because they could
be tagged with none.
In the long run as well other entities might need to be tagged and other taggable entities might appear.
class Article(models.Model):
#Fields
class Picture(models.Model):
#Fields
class Presenter(models.Model):
# Fields
class Event(models.Model):
# Fields
The closer I am getting is to some kind of double-headed Generic contenttype based intermediate model like this(haven't tested yet as it is a bit more complex than that), but I am looking for ideas:
class GenericTag(models.Model):
# Event,Presenter instance..
tagcontent_type = models.ForeignKey(ContentType)
tagobject_id = models.PositiveIntegerField()
tagcontent_object = generic.GenericForeignKey('tagcontent_type', 'tagobject_id')
# Picture,Article instance
objcontent_type = models.ForeignKey(ContentType)
objobject_id = models.PositiveIntegerField()
objcontent_object = generic.GenericForeignKey('objcontent_type', 'objobject_id')
And with that just do queries based on the information I have, I think there have to be more elegant ways to do this without stuffing all tagmodels as fields into taggablemodels.
{%gettags currentband Article as articles_for_currentband%}
{%gettags Bands currentarticle as bandtags_for_this_article%}
{%tagcount currentband %}