Package django :: Package contrib :: Package auth :: Module models :: Class User
[hide private]
[frames] | no frames]

Class User

source code

db.models.Model --+
                  |
                 User

Users within the Django authentication system are represented by this model.

Username and password are required. Other fields are optional.

Nested Classes [hide private]
  Meta
  Admin
Instance Methods [hide private]
 
__unicode__(self) source code
 
get_absolute_url(self) source code
 
is_anonymous(self)
Always returns False.
source code
 
is_authenticated(self)
Always return True.
source code
 
get_full_name(self)
Returns the first_name plus the last_name, with a space in between.
source code
 
set_password(self, raw_password) source code
 
check_password(self, raw_password)
Returns a boolean of whether the raw_password was correct.
source code
 
set_unusable_password(self) source code
 
has_usable_password(self) source code
 
get_group_permissions(self)
Returns a list of permission strings that this user has through his/her groups.
source code
 
get_all_permissions(self) source code
 
has_perm(self, perm)
Returns True if the user has the specified permission.
source code
 
has_perms(self, perm_list)
Returns True if the user has each of the specified permissions.
source code
 
has_module_perms(self, app_label)
Returns True if the user has any permissions in the given app label.
source code
 
get_and_delete_messages(self) source code
 
email_user(self, subject, message, from_email=None)
Sends an e-mail to this User.
source code
 
get_profile(self)
Returns site-specific profile for this user.
source code
Class Variables [hide private]
  username = models.CharField(_('username'), max_length= 30, uni...
  first_name = models.CharField(_('first name'), max_length= 30,...
  last_name = models.CharField(_('last name'), max_length= 30, b...
  email = models.EmailField(_('e-mail address'), blank= True)
  password = models.CharField(_('password'), max_length= 128, he...
  is_staff = models.BooleanField(_('staff status'), default= Fal...
  is_active = models.BooleanField(_('active'), default= True, he...
  is_superuser = models.BooleanField(_('superuser status'), defa...
  last_login = models.DateTimeField(_('last login'), default= da...
  date_joined = models.DateTimeField(_('date joined'), default= ...
  groups = models.ManyToManyField(Group, verbose_name= _('groups...
  user_permissions = models.ManyToManyField(Permission, verbose_...
  objects = UserManager()
Method Details [hide private]

is_anonymous(self)

source code 

Always returns False. This is a way of comparing User objects to anonymous users.

is_authenticated(self)

source code 

Always return True. This is a way to tell if the user has been authenticated in templates.

check_password(self, raw_password)

source code 

Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes.

get_group_permissions(self)

source code 

Returns a list of permission strings that this user has through his/her groups. This method queries all available auth backends.

has_perm(self, perm)

source code 

Returns True if the user has the specified permission. This method queries all available auth backends, but returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general.

has_module_perms(self, app_label)

source code 

Returns True if the user has any permissions in the given app label. Uses pretty much the same logic as has_perm, above.

get_profile(self)

source code 

Returns site-specific profile for this user. Raises SiteProfileNotAvailable if this site does not allow profiles.


Class Variable Details [hide private]

username

Value:
models.CharField(_('username'), max_length= 30, unique= True, validato\
r_list= [validators.isAlphaNumeric], help_text= _("Required. 30 charac\
ters or fewer. Alphanumeric characters only (letters, digits and under\
scores)."))

first_name

Value:
models.CharField(_('first name'), max_length= 30, blank= True)

last_name

Value:
models.CharField(_('last name'), max_length= 30, blank= True)

password

Value:
models.CharField(_('password'), max_length= 128, help_text= _("Use '[a\
lgo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change passw\
ord form</a>."))

is_staff

Value:
models.BooleanField(_('staff status'), default= False, help_text= _("D\
esignates whether the user can log into this admin site."))

is_active

Value:
models.BooleanField(_('active'), default= True, help_text= _("Designat\
es whether this user should be treated as active. Unselect this instea\
d of deleting accounts."))

is_superuser

Value:
models.BooleanField(_('superuser status'), default= False, help_text= \
_("Designates that this user has all permissions without explicitly as\
signing them."))

last_login

Value:
models.DateTimeField(_('last login'), default= datetime.datetime.now)

date_joined

Value:
models.DateTimeField(_('date joined'), default= datetime.datetime.now)

groups

Value:
models.ManyToManyField(Group, verbose_name= _('groups'), blank= True, \
help_text= _("In addition to the permissions manually assigned, this u\
ser will also get all permissions granted to each group he/she is in."\
))

user_permissions

Value:
models.ManyToManyField(Permission, verbose_name= _('user permissions')\
, blank= True, filter_interface= models.HORIZONTAL)