Commits

Sergiy Kuzmenko committed 315a4df

markdown please

Comments (0)

Files changed (2)

+AUTH SHORTCUTS
+--------------
+
+``xdjango.contrib.auth.shortcuts`` defines two handy function for retrieving users
+by permission. Permissions could be defined directly for the user or via groups.
+
+
+get_users_by_permission(permission_name, include_superusers=True)
+=================================================================
+
+Returns the queryset of User objects with the given permission. Permission name
+is in the form appname.permission, same format as used by
+``django.contrib.auth.decorators.permission_required``. If ``include_superusers``
+is set to False this function will only return users with explicitely set
+permissions.
+
+
+q_users_by_permission(permission_name, include_superusers=True)
+===============================================================
+
+Like get_users_by_permission but returns a Q object instead of queryset. Handy to
+use in model definitions with limit_choices_to:
+
+    class Task(models.Model):
+        name = models.CharField(max_length=128)
+        user = models.ForeignKey(
+            User,
+            limit_choices_to=q_users_by_permission("myapp.change_task")
+        )
+
+
+Troubleshooting
+================
+
+Users with overlapping permissions (e.g., the same permission is assigned via
+multiple groups) may appear multiple times in the queryset. To adress this problem remove
+duplicate permissions for the user or use the ``distinct()`` clause on the queryset:
+
+    get_users_by_permission("myapp.change_task").distinct()
+

docs/auth.txt

-AUTH SHORTCUTS
---------------
-
-``xdjango.contrib.auth.shortcuts`` defines two handy function for retrieving users
-by permission. Permissions could be defined directly for the user or via groups.
-
-
-get_users_by_permission(permission_name, include_superusers=True)
-=================================================================
-
-Returns the queryset of User objects with the given permission. Permission name
-is in the form appname.permission, same format as used by
-``django.contrib.auth.decorators.permission_required``. If ``include_superusers``
-is set to False this function will only return users with explicitely set
-permissions.
-
-
-q_users_by_permission(permission_name, include_superusers=True)
-===============================================================
-
-Like get_users_by_permission but returns a Q object instead of queryset. Handy to
-use in model definitions with limit_choices_to:
-
-    class Task(models.Model):
-        name = models.CharField(max_length=128)
-        user = models.ForeignKey(
-            User,
-            limit_choices_to=q_users_by_permission("myapp.change_task")
-        )
-
-
-Troubleshooting
-================
-
-Users with overlapping permissions (e.g., the same permission is assigned via
-multiple groups) may appear multiple times in the queryset. To adress this problem remove
-duplicate permissions for the user or use the ``distinct()`` clause on the queryset:
-
-    get_users_by_permission("myapp.change_task").distinct()
-