You should be able to use the standard Python getattr call: print getattr(tag, 'model_name').count()
which dynamically gets an attribute passed as a string. -- Daniel. On 30 Jan, 06:22, Chris <[EMAIL PROTECTED]> wrote: > Hello I have a Tagging app that I have created which could have a m2m > relation with several other applications suchas a weblog, projects, > articles,etc... > > I am trying to do something like this: > > tag_list = Tag.objects.all() > > for tag in tag_list: > print tag.weblog.count() > > Is there a way to dynamically call tag.[this_model].count(). since > this tagging app can be associated with more than one app. (replacing > this_model with the appropriate model name.) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---