def change_user(self, **kwargs): user = UserFactory() form_for_data = UserChangeForm(instance=user) post_data = form_for_data.initial post_data.update(kwargs) form = UserChangeForm(instance=user, data=post_data) form.save() user.refresh_from_db() return user
def change_user(self, **kwargs): user = UserFactory() ma = UserAdmin(User, AdminSite()) UserChangeForm = ma.get_form(request, user, change=True) form_for_data = UserChangeForm(instance=user) post_data = form_for_data.initial post_data.update(kwargs) form = UserChangeForm(instance=user, data=post_data) form.save() user.refresh_from_db() return user