Here's the script. I manually entered ContentType entries for proxy objects and then created new permissions for them.
It just generates sql, which should then be run in mysql. After that, they should appear in the list of permissions for the user, where they will need to be added. Some of the naming conventions are not obvious to them.
your_models=['proxy model', ] for model in models: model_nospace = model.replace(' ','') sql = 'insert into django_content_type (name, app_label, model) values ("%s","<<app_name>>","%s");'%(model,model_nospace) print sql for kind, permname in [('Can add','add_%s'%model_nospace), ('Can change','change_%s'%model_nospace), ('Can delete','delete_%s'%model_nospace),]: sql = 'insert into auth_permission (name, content_type_id, codename) values ("%s %s",(select id from django_content_type where name="%s"),"%s");'% (kind,model,model,permname) print sql
fastmultiplication
source share