草庐IT

auth_user

全部标签

python - AUTH_USER_MODEL指的是型号 'accounts.User'还没有安装

我正在使用自定义用户模型,使用AbstractUser进行扩展。这是我的models.py:#-*-coding:utf-8-*-from__future__importunicode_literalsfromdjango.dbimportmodelsfromdjango.contrib.auth.modelsimportAbstractUserfromdjango.contrib.auth.formsimportUserCreationFormfromdjangoimportforms#Createyourmodelshere.classUser(AbstractUser):pass

python - Django Custom User --- 在 admin 中编辑新的 CustomUser 字段

我正在尝试扩展下面发布的WilliamVincent教程:https://wsvincent.com/django-custom-user-model-tutorial/我正在尝试通过从django.contrib.auth.models导入的AbstractUser向CustomerUser模型添加新字段:用户/模型.py:fromdjango.dbimportmodelsfromdjango.contrib.auth.modelsimportAbstractUser,UserManagerclassCustomUserManager(UserManager):passclassCu

python - flask 管理员/ flask -SQLAlchemy : set user_id = current_user for INSERT

我使用Flask-Admin+Flask-SQLAlchemy定义了三个模型:User、Apikey、Exchange。当经过身份验证的用户通过Web管理界面创建新的Apikey时,我希望将插入数据库的新行上的user_id设置为当前登录的user_id。在我当前的实现中,用户可以选择她喜欢的任何用户(这不是我们想要的)。这是我对模型的定义:classUser(db.Model,UserMixin):id=db.Column(db.Integer,primary_key=True)first_name=db.Column(db.String(255))last_name=db.Colu

python - python proxy-auth 中的 phantomjs + selenium 不工作

我正在尝试使用selenium+phantomjs为网络抓取设置代理。我正在使用python。我在很多地方看到phantomjs中有一个错误,代理验证不起作用。fromselenium.webdriver.common.proxyimport*fromseleniumimportwebdriverfromselenium.webdriver.common.byimportByservice_args=['--proxy=http://fr.proxymesh.com:31280','--proxy-auth=USER:PWD','--proxy-type=http',]driver=w

python - Django 1.9 错误 - 'User' 对象没有属性 'profile'

所以我最近添加了一个可选的用户配置文件模型,它通过OneToOneField链接到用户,如下所示:classUserProfile(models.Model):#Creatingclassuser=models.OneToOneField(User,on_delete=models.CASCADE)这工作正常,我当前的UserProfile模型在我添加此字段以将配置文件链接到用户之前和之后都完好无损。当我以有效用户身份登录网站时,提交登录表单后出现错误:AttributeErrorat/login/'User'objecthasnoattribute'profile'我已经在我的文件中

python - Django Auth LDAP - 使用 sAMAccountName 直接绑定(bind)

有两种使用DjangoAuthLDAP验证用户身份的方法搜索/绑定(bind)和直接绑定(bind)。第一个涉及匿名或使用固定帐户连接到LDAP服务器并搜索身份验证用户的可分辨名称。然后我们可以尝试使用用户密码再次绑定(bind)。第二种方法是从用户名中获取用户的DN并尝试直接绑定(bind)为用户。我希望能够使用尝试访问应用程序的用户的用户ID(sAMAccountName)和密码进行直接绑定(bind)。请让我知道是否有办法实现这一目标?目前,由于下面解释的问题,我似乎无法完成这项工作。在我的例子中,LDAP中用户的DN格式如下**'CN=StevenJones,OU=Users,

python - 具有唯一电子邮件的 Django auth.user

我使用django.auth系统并且我有这个:classRegisterForm(UserCreationForm):username=forms.RegexField(label="Username",max_length=30,regex=r'^[\w]+$',error_messages={'invalid':"Thisvaluemaycontainonlyletters,numbersand_characters."})email=forms.EmailField(label="Email")first_name=forms.CharField(label="Firstname

Android安装apk应用的时候出现INSTALL_FAILED_SHARED_USER_INCOMPATIBLE如何解决

前言如果你安装app时出现INSTALL_FAILED_SHARED_USER_INCOMPATIBLE的错误那么你大概率在manifest文件中增加了android:sharedUserId="android.uid.system",此属性的作用是将普通app提升为系统app(这样就能使用一些系统权限,例如在应用外显示弹窗)针对此问题,网上大部分讨论的是去除android:sharedUserId这个属性,但是如果你的目的就是想使用此属性,并且能安装上去,那么请尝试下面的解决方法。注意:使用android:sharedUserId的同时,还需要android系统的key,不同的系统的key都

python - django-social-auth : How to redirect example. com 到 127.0.0.1 :8000?

我相信许多Django开发人员在使用社交身份验证时一定会遇到这个问题。最初当你开发它时,你想在你的本地服务器上测试它,因此你会在你的etc/hosts中重定向域名。我在文档中发现了这一点:https://github.com/omab/django-social-auth#facebookIfyoudefinearedirectURLinFacebooksetuppage,besuretonotdefinehttp://localhost:8000becauseitwon'tworkwhentesting.InsteadIdefinehttp://myapp.comandsetupam

python - Django 模型中的 request.user

我正在使用Django模型为表单创建字段。我希望自动检测并填写用户的用户名,这样我就可以将其隐藏在我的表单中(而不是让他们从拥有每个人用户名的长列表中选择他们的用户名)。为此,我正在使用:current_user=request.user然后将默认设置为current_user。但是,我不断收到此错误:NameError:name'request'isnotdefined我假设您不能在Django模型中使用请求,但是有什么方法可以解决这个问题吗?这是我的models.py文件的相关部分:classStockTickerSymbol(models.Model):StockName=mod