diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
index 52ddf22..df8ad50 100644
a
|
b
|
data-access methods like any other :doc:`Django model </ref/models/instances>`.
|
1295 | 1295 | |
1296 | 1296 | .. currentmodule:: django.contrib.auth |
1297 | 1297 | |
| 1298 | |
| 1299 | Programmatically creating permissions |
| 1300 | ------------------------------------- |
| 1301 | |
| 1302 | While custom permissions can be defined within a model's ``Meta`` class, you |
| 1303 | can also create permissions directly. For example, you can create the ``can_publish`` |
| 1304 | permission for a ``BlogPost`` model in ``myapp``:: |
| 1305 | |
| 1306 | from django.contrib.auth.models import Group, Permission |
| 1307 | from django.contrib.contenttypes.models import ContentType |
| 1308 | |
| 1309 | content_type = ContentType.objects.get(app_label='myapp', model='BlogPost') |
| 1310 | perm = Permission.objects.create(codename='can_publish', name='Can Publish Posts', |
| 1311 | content_type=content_type) |
| 1312 | |
| 1313 | The permission can be assigned to a :class:`~django.contrib.auth.models.User` via |
| 1314 | ``user_permissions`` or a :class:`~django.contrib.auth.models.Group` via |
| 1315 | ``permissions``. |
| 1316 | |
| 1317 | |
1298 | 1318 | Authentication data in templates |
1299 | 1319 | ================================ |
1300 | 1320 | |
… |
… |
group ``'Special users'``, and you could write code that could, say, give them
|
1387 | 1407 | access to a members-only portion of your site, or send them members-only e-mail |
1388 | 1408 | messages. |
1389 | 1409 | |
| 1410 | .. class:: models.Group |
| 1411 | |
| 1412 | API reference |
| 1413 | ------------- |
| 1414 | |
| 1415 | Fields |
| 1416 | ~~~~~~ |
| 1417 | |
| 1418 | .. class:: models.Group |
| 1419 | |
| 1420 | :class:`~django.contrib.auth.models.Group` objects have the |
| 1421 | following fields: |
| 1422 | |
| 1423 | .. attribute:: models.Group.name |
| 1424 | |
| 1425 | Required. 80 characters or fewer. Any characters are permitted. |
| 1426 | |
| 1427 | .. attribute:: models.Group.permissions |
| 1428 | |
| 1429 | Many-to-many field to :class:`~django.contrib.auth.models.Permissions`:: |
| 1430 | |
| 1431 | group.permissions = [permission_list] |
| 1432 | group.permissions.add(permission, permission, ...) |
| 1433 | group.permissions.remove(permission, permission, ...) |
| 1434 | group.permissions.clear() |
| 1435 | |
1390 | 1436 | Messages |
1391 | 1437 | ======== |
1392 | 1438 | |