def get_model_perms(model):
    """
    Get permission-string list of a specified django model.

    Parameters
    ----------
    model : model class
        A model class to specify the particular django model.

    Returns
    -------
    set
        A set of perms of the specified django model.

    Examples
    --------
    >>> sorted(get_model_perms(Permission)) == [
    ...     'auth.add_permission',
    ...     'auth.change_permission',
    ...     'auth.delete_permission'
    ... ]
    True
    """
    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)
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 )
Get permission-string list of a specified django model.

    Parameters
    ----------
    model : model class
        A model class to specify the particular django model.

    Returns
    -------
    set
        A set of perms of the specified django model.

    Examples
    --------
    >>> sorted(get_model_perms(Permission)) == [
    ...     'auth.add_permission',
    ...     'auth.change_permission',
    ...     'auth.delete_permission'
    ... ]
    True