On Apr 16, 6:02 pm, Matthew <matthew.vix...@gmail.com> wrote: > Is it possible to do this? > > I'm using a custom MultiQuerySet snippet to merge a bunch of querysets > from different models, and then I want to iterate over the resultant > list, but I want to be able to pull out from each object in the list > its own Model type so I can perform a few comparisons/functions. Short > of writing a method into each model, I can't think of anyway it could > be done, and that won't work because I want to throw Comments into > that merged queryset too. > > Help would be much appreciated, > Thanks > Matt
There's a couple of ways. You could use the built-in Python attribute __class__ that exists on every object. This returns a class object. Or, you could use some of the data in the _meta subclass of each Django model. For instance, x._meta.object_name gives the name of x's model type. Do dir(x._meta) to get a list. -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---