Even after obj.save(), the obj still does not have an id, so I cannot access or manipulate the m2m records. Just keep getting a "instance needs to have a primary key value before a many-to-many relationship can be used" error.
def save_model(self, request, obj, form, change):
obj.save() # this doesn't work
super(Table2Admin, self).save_model(request, obj, form, change) # still doesn't save
for tb1 in obj.table1.all:
tb1_obj = ThroughTable.objects.get(table1=tb1, table2=obj)
# do other stuff
tb1.save()
What am I doing wrong? What do I need to do to save this model?
Update: After updating to the latest svn of django, the obj.save() does seem to be working, however, I'm still having a problem. For a split second, the changes that I'm making to the ThroughTable object are saved, but then they are almost immediately overwritten. On a table with m2m data, does save() delete all the m2m records and then recreate them...?