django-contrib

Django - Read the current's user authentication backend class

穿精又带淫゛_ 提交于 2019-12-10 17:15:59
问题 I am using a custom authentication backend with Django, to automatically create and login users from a legacy system. My Backend class is this: from django.contrib.auth.backends import ModelBackend from django.contrib.auth.models import User from sfi.models import Employee import base64, hashlib class SFIUserBackend(ModelBackend): def authenticate(self, username=None, password=None): if not username or not password: return digest = base64.standard_b64encode(hashlib.md5(password).digest())

django: failing tests from django.contrib.auth

China☆狼群 提交于 2019-12-07 08:00:26
问题 When I run my django test I get following errors, that are outside of my test suite: ====================================================================== ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 160, in test_known_user super(RemoteUserCustomTest, self).test_known

django: failing tests from django.contrib.auth

大憨熊 提交于 2019-12-05 08:32:36
When I run my django test I get following errors, that are outside of my test suite: ====================================================================== ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 160, in test_known_user super(RemoteUserCustomTest, self).test_known_user() File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 67, in test

request.user returns a SimpleLazyObject, how do I “wake” it?

不羁的心 提交于 2019-11-28 06:41:22
I have the following method: def _attempt(actor): if actor.__class__ != User: raise TypeError Which is called from a view: self.object.attempt(self.request.user) As you can see, the _attempt method expects actor to be type django.contrib.auth.models.User , however the object appears to be of type django.utils.functional.SimpleLazyObject . Why is this so? And more importantly, how can I convert the LazyObject (which apparently is a kind of wrapper for a User object) into a User object? More info on Request.user is available here: https://docs.djangoproject.com/en/dev/ref/request-response/

Django: Why create a OneToOne to UserProfile instead of subclassing auth.User?

删除回忆录丶 提交于 2019-11-27 20:50:20
Note: If you are tempted to 'answer' this question by telling me that you don't like django.contrib.auth, please move on. That will not be helpful. I am well aware of the range and strength of opinions on this matter. Now, the question: The convention is to create a model, UserProfile, with a OneToOne to User. In every way I can think of, a more efficient and effective approach is to subclass User to a class that one intends to use for every human in the system - a class called, say, Person(User). I have not seen a coherent explanation of why the former is conventional and the latter is

request.user returns a SimpleLazyObject, how do I “wake” it?

流过昼夜 提交于 2019-11-27 01:32:02
问题 I have the following method: def _attempt(actor): if actor.__class__ != User: raise TypeError Which is called from a view: self.object.attempt(self.request.user) As you can see, the _attempt method expects actor to be type django.contrib.auth.models.User , however the object appears to be of type django.utils.functional.SimpleLazyObject . Why is this so? And more importantly, how can I convert the LazyObject (which apparently is a kind of wrapper for a User object) into a User object? More

Django: Why create a OneToOne to UserProfile instead of subclassing auth.User?

。_饼干妹妹 提交于 2019-11-26 20:28:13
问题 Note: If you are tempted to 'answer' this question by telling me that you don't like django.contrib.auth, please move on. That will not be helpful. I am well aware of the range and strength of opinions on this matter. Now, the question: The convention is to create a model, UserProfile, with a OneToOne to User. In every way I can think of, a more efficient and effective approach is to subclass User to a class that one intends to use for every human in the system - a class called, say, Person