I am trying to access the field(s) of a Child table while still inside
the save method of the Parent table.

Assuming that the many-to-many field in the Parent table is called
`m2m_field`, and the field I need to access in the Child table is
called `child_field`, what I have tried is this:

def save_model(self, request, obj, form, change):
    # save object and the many-to-many data
    obj.save()
    # this does not work:
    data_I_need = obj.m2m.all()[0].child_field
    # nor does this:
    data_I_need = Parent.objects.get(pk=obj.pk).m2m.all()[0].child_field
    # in fact, length is 0, so no data in the set...
    print len(Parent.objects.get(pk=obj.pk).m2m.all())

I know I am not grasping some key aspect of the problem; but I cannot
see what it is, and would appreciate any help with this problem!

Thanks
Derek

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to