_set.all()

140 views
Skip to first unread message

David

unread,
Jul 27, 2012, 10:04:00 AM7/27/12
to django...@googlegroups.com
Hello

This may be more of a Python question that a Django question, but ... I am trying to make one of my apps more abstract.

Using _set.all() I can return all of the m2m relations. I can then loop through them doing what I like providing I know the model field names.

if not isinstance(f, GenericRelation):
    for a in value.all():
        # do something such as
        # print a.topic

If I don't know the name "topic" how can I reference it? or is this not possible?

Thank you

David

unread,
Jul 27, 2012, 10:09:31 AM7/27/12
to django...@googlegroups.com
hmm nvm

print unicode(a)

seems to do the trick.
Reply all
Reply to author
Forward
0 new messages