Friday, July 27, 2012

_set.all()

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/f-FYA_wfNmMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment