On Sun, 2008-02-17 at 00:50 -0800, Jamie Pittock wrote: > Hi, > > I'm wanting to create a "tumblelog" of sorts made up of content from > several different models within my site and I'm looking for > suggestions on the best way of accomplishing it. The two ideas I have > so far are: > > 1. Combine the results from different queries into one (as already > discussed here - > http://groups.google.com/group/django-users/browse_frm/thread/4a37a6b2cf6b34d6/d23994d6c6765170?lnk=gst&q=sorting&rnum=4#d23994d6c6765170) > > 2. Use the contenttypes framework and create a generic TumblelogItem > Model that would hold the content_type and ids of all the model items > I'd like to "tumble". Something like... > > class TumbleLogItem(models.Model): > author = models.ForeignKey(User) > pub_date = models.DateTimeField() > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField() > content_object = models.GenericForeignKey() > > Does anyone have any advice on the use of either of these two > options? Or is there a better third way?
Take note of a fairly significant behavioural difference between these two solutions: the second one allows you finer-grained control over which items from the related models are going to be displayed. Probably important for a tumblelog. It keeps the "which data is public for tumblelog purposes" in the one place (having a "public" flag on each model might not work, since public in one instance might not mean public for, say, tumblelog purposes). Also, the second solution is more extensible, in the sense that if you're going to add more models later, it won't require code changes. Still, the first solution requires less code. So it very much depends on what your source models look like and how fluid your setup might be. If I was writing a generic tumblelog application (which I've never done -- hopefully people with actual experience here will also respond), I'd probably use something like your second model, since it requires no knowledge of other models until you start to use it. Consequently, it's more portable. Regards, Malcolm -- The early bird may get the worm, but the second mouse gets the cheese. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---