Remove (or hide) default Permissions from Django

前端 未结 8 1194
醉酒成梦
醉酒成梦 2021-01-30 17:53

I\'m developing a Django app that will have two administration backends. One for daily use by \"normal\" users and the default one for more advanced tasks and for the developers

8条回答
  •  不知归路
    2021-01-30 18:41

    If you want to prevent Django from creating permissions, you can block the signals from being sent.

    If you put this into a management/init.py in any app, it will bind to the signal handler before the auth framework has a chance (taking advantage of the dispatch_uid debouncing).

    from django.db.models import signals
    
    def do_nothing(*args, **kwargs):
      pass
    
    signals.post_syncdb.connect(do_nothing, dispatch_uid="django.contrib.auth.management.create_permissions")
    signals.post_syncdb.connect(do_nothing, dispatch_uid="django.contrib.auth.management.create_superuser")
    

提交回复
热议问题