I am using save_model to add an User to particular Group
def UserAdmin(UserAdmin):
def save_model(self, request, obj, form, change):
adminOb = Group.objects.get(name='Administrator')
adminOb.user_set.add(obj.pk)
adminOb.save()
obj.save()
This code is not adding the obj.pk
to `adminOb' the but when I do this in terminal I am able to save
In terminal I did this
adminOb = Group.objects.get(name='Administrator')
adminOb.user_set.add(44)
adminOb.save()
Note : I use werkzeug debugging tool, via which I can console in browser, I tested in this console, for the console to appear in the browser the page should have some error, so instead of adminOb.save()
I used adminOb.saved()
,then in console I run this adminOb.save()
, Surprisingly this is saving the adminOb