I'm trying to allow users to watch items, and have that working.
Problem is, on the template I want to sort by content type and have a
header for each one, something like:

Foo:
  item 1
  item 2

Bar:
  item 1
  item 2

In the model, I've established a generic relation:

class Watch(models.Model):
    subscriber = models.ForeignKey(User, verbose_name="Subscriber")
    content_type = models.ForeignKey(ContentType)
    content_object = models.GenericForeignKey()
    object_id = models.IntegerField(_('object ID'))


Then in the view I'm building a list of the objects the user is
watching (slug is their username):

def watchlist(request, slug):
    user = User.objects.get(username=slug)
    watch_list = []
    watch_items = Watch.objects.filter(subscriber=user)
    for i in watch_items:
        thismodel = get_model(i.content_type.app_label,
i.content_type.model)
        objects = thismodel.objects.filter(id=i.object_id)
        watch_list += objects
    return render_to_response('watchlist/watch_list_user.html',
{'watch_list': watch_list}, context_instance=RequestContext(request))

The problem is that my watch_list has no idea what content type the
objects are. I've tried a lot of things, and can get the content type,
but then can't seem to get the objects. Any suggestions?


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to