Hi,
I gave details on my code : I don't know why my table is empty (it seems that it was empty out after calling save_model
, but I'm not sure).
class PostAdmin(admin.ModelAdmin):
def save_model(self, request, post, form, change):
post.save()
# Authors must be saved after saving post
print form.cleaned_data['authors'] # []
print request.user # pg
authors = form.cleaned_data['authors'] or request.user
print authors # pg
post.authors.add(authors)
print post.authors.all() # [<User: pg>]
# But on a shell, table is empty. WTF ?! :
# select * from journal_post_authors;
# Empty set (0.00 sec)