Hi,
Maybe I focused too much on the type of solution I was looking for and not
on the problem itself.

Let's try with music:

I have a Bands application with a Band model that can be used for CRUD of
band entity and for voting bands, commenting on them etc..
I have a Venue application  with a Venue model that can be used for CRUD of
venue entity and "" "" ....

I have a Media application that contains a Picture model that is used for
storing pics, commenting etc...
I have an Articles application that contains an Article model that people
use to write post-like articles writing about bands or venues or whateveer.
I have an Events application that conains an Event model that people use to
describe when and how an event will happen.

Now, as a side note, almost all of those models have comments through
django.contrib.comments plugged in by their own application, model
untouched.

What I would like to do is to be able of tagging Pictures,Articles and
Events with Bands, Venues, a combination of several of each or none at all.
Plus to the Band and Venue model types I will be adding soon other models
as Promoter etc.. that could be tagged as well in any of the others.

The kind of information I am going to read is like:

   - For this Article give me bands
   - For this Picture give me venues and bands
   - For this Event give me venues
   - For this Band how many entities are tagged(Pictures,Articles...),
   retrieve them
   - For this Venue give me pictures


To me it is the same pattern over and over with different entities on both
sides, so I was looking for a generic way of handling it.

Following the external approach of django.contrib.comments, something like
this:

Example:

> {%gettags currentband Article as articles_for_currentband%}
> {%gettags Bands currentarticle as bandtags_for_this_article%}
> {%tagcount currentband %}
>


--
Arkaitz


On Tue, Feb 7, 2012 at 7:11 PM, arkai...@gmail.com <arkai...@gmail.com>wrote:

> 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.
> So, basically, there are several "taggable" objects and "tag" objects
> which will never overlap and I would like a way of relating them with
> django without touching the models themselves as they are entities of their
> own apps.
>
> I was looking into a proxy model with a many2many field, but cannot add
> fields to proxy models.
>
> Thanks
>
> --
> Arkaitz
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to