1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[soc2009/multidb] Merged up to trunk r11917.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11920 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor
2009-12-19 18:03:58 +00:00
parent df2746b16c
commit 42c03cbeae
19 changed files with 284 additions and 15 deletions

View File

@@ -225,8 +225,9 @@ Methods
.. method:: models.User.has_perm(perm, obj=None)
Returns ``True`` if the user has the specified permission, where perm is
in the format ``"<app label>.<permission codename>"``.
If the user is inactive, this method will always return ``False``.
in the format ``"<app label>.<permission codename>"``. (see
`permissions`_ section below). If the user is inactive, this method will
always return ``False``.
.. versionadded:: 1.2
@@ -1122,6 +1123,8 @@ generic view itself. For example::
def limited_object_detail(*args, **kwargs):
return object_detail(*args, **kwargs)
.. _permissions:
Permissions
===========
@@ -1164,6 +1167,14 @@ models being installed at that time. Afterward, it will create default
permissions for new models each time you run :djadmin:`manage.py syncdb
<syncdb>`.
Assuming you have an application with an
:attr:`~django.db.models.Options.app_label` ``foo`` and a model named ``Bar``,
to test for basic permissions you should use:
* add: ``user.has_perm('foo.add_bar')``
* change: ``user.has_perm('foo.change_bar')``
* delete: ``user.has_perm('foo.delete_bar')``
.. _custom-permissions:
Custom permissions

View File

@@ -264,7 +264,7 @@ name::
class PersonManager(models.Manager):
def get_by_natural_key(self, first_name, last_name):
return self.filter(first_name=first_name, last_name=last_name)
return self.get(first_name=first_name, last_name=last_name)
class Person(models.Model):
objects = PersonManager()