code: def get_model_perms(model):
      from django.contrib.auth.models import Permission
      app_label = model._meta.app_label
      model_name = model._meta.object_name.lower()
      qs = Permission.objects.filter(content_type__app_label=app_label,
                                     content_type__model=model_name)
      perms = ('%s.%s' % (app_label, p.codename) for p in qs.iterator())
      return set(perms)