Did you define the "Actions" as a separate table with a "person" and
"act" field, or did you define "actions" as a ManyToManyField for one
of the other table/classes? If so, Django creates the appropriate
helper method (such as get_activity_list) to show the activities for a
given person, as in:

p = persons.get_object(pk=1)
p.get_activity_list()

and in the Admin interface, you get (by default) a "select" tag with
multiple selection enabled. The select control has the "friendly" names
for the activities.

If you want to have a method which aggregates all of the People and
Activities for those people, you could define a class method for the
class with the ManyToManyField in it. I'm not sure if I'm re-inventing
the wheel or if there is a better way to do it, but it worked for me.

    def _module_activities_by_person():
        return [(p,p.get_activity_list()) for p in get_list()]

You could then use the resulting list in a template to show all of the
information in a friendly way. You could probably also accomplish the
same thing in a template using "for" tags appropriately.

If you are just interested in a data entry scenario, the Admin
interface should do it correctly in that case.

Reply via email to