| 13 | """Django comes with a user authentication system. It handles user accounts, groups, permissions and cookie-based user sessions. Permissions are represented by this model. The permissions system provides a way to assign permissions to specific users and groups of users. |
| 14 | |
| 15 | The permission system is used by the Django admin site, but you're welcome to use it in your own code. The Django admin site uses permissions as follows: |
| 16 | |
| 17 | * Access to view the "add" form and add an object is limited to users with the "add" permission for that type of object. |
| 18 | * Access to view the change list, view the "change" form and change an object is limited to users with the "change" permission for that type of object. |
| 19 | * Access to delete an object is limited to users with the "delete" permission for that type of object. |
| 20 | |
| 21 | Permissions are set globally per type of object, not per specific object instance. For example, it's possible to say "Mary may change news stories," but it's not currently possible to say "Mary may change news stories, but only the ones she created herself" or "Mary may only change news stories that have a certain status or publication date." The latter functionality is something Django developers are currently discussing. |
| 22 | |
| 23 | Three basic permissions -- add, create and delete -- are automatically created for each Django model that has admin set. |
| 24 | """ |
26 | | name = models.CharField(_('name'), maxlength=80, unique=True) |
| 38 | """Django comes with a user authentication system. It handles user accounts, groups, permissions and cookie-based user sessions. Groups are represented by this model. |
| 39 | |
| 40 | Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups. |
| 41 | |
| 42 | A user in a group automatically has the permissions granted to that group. For example, if the group Site editors has the permission can_edit_home_page, any user in that group will have that permission. |
| 43 | |
| 44 | Beyond permissions, groups are a convenient way to categorize users to apply some label, or extended functionality, to them. For example, you could create a group 'Special users', and you could write code that would do special things to those users -- such as giving them access to a members-only portion of your site, or sending them members-only e-mail messages. |
| 45 | """ |
| 46 | name = models.CharField(_('name'), maxlength=80, unique=True, help_text=_("Required. 80 characters or fewer.")) |
55 | | username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric]) |
| 75 | """Django comes with a user authentication system. It handles user accounts, groups, permissions and cookie-based user sessions. Users are represented by this model. |
| 76 | |
| 77 | Username and password are required, other fields are optional. |
| 78 | """ |
| 79 | username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores).")) |
56 | 80 | first_name = models.CharField(_('first name'), maxlength=30, blank=True) |
57 | 81 | last_name = models.CharField(_('last name'), maxlength=30, blank=True) |
58 | 82 | email = models.EmailField(_('e-mail address'), blank=True) |
59 | 83 | password = models.CharField(_('password'), maxlength=128, help_text=_("Use '[algo]$[salt]$[hexdigest]'")) |
60 | 84 | is_staff = models.BooleanField(_('staff status'), help_text=_("Designates whether the user can log into this admin site.")) |