Django non unique username field warning

In my django app I have a custom user model with a username field called my_username . Recently I made this field non unique (actually it is now unique_together with another field). This makes django to emit the following warning in manage.py : (auth.W004) 'MyUser.my_username' is named as the 'USERNAME_FIELD', but it is not unique. HINT: Ensure that your authentication backen

Django非唯一的用户名字段警告

在我的Django应用程序中,我有一个名为my_username的用户名字my_username的自定义用户模型。 最近我做了这个领域中的非唯一的(其实现在unique_together与另一场)。 这使得django在manage.py发出以下警告: (auth.W004)'MyUser.my_username'被命名为'USERNAME_FIELD',但它不是唯一的。 提示:确保您的身份验证后端可以处理非唯一的用户名。 有没有办法阻止这个警告显示? 我只找到了禁用所有警告的

Use JWT Auth for authenticate against LDAP service

I'm creating a web services that use JWT Auth. I'm using django-rest-framework-jwt for that. I want my users could authenticate using their ldap accounts. I have found that there's a Django authentication backend that authenticates against an LDAP service. The function that does the authentication in django-rest-framework-jwt is coded like this : def authenticate_credentials(self

使用JWT Auth进行LDAP服务验证

我正在创建一个使用JWT身份验证的Web服务。 我为此使用了django-rest-framework-jwt。 我希望我的用户可以使用他们的LDAP帐户进行身份验证。 我发现有一个Django身份验证后端根据LDAP服务进行身份验证。 在django-rest-framework-jwt中进行身份验证的函数编码如下: def authenticate_credentials(self, payload): try: user_id = payload.get('user_id') if user_id: user = User.objects

How to have django auth take username and firstname same value?

Django auth has username and first_name fields. But username has field option unique=True. This prevents a user from giving first_name same as username when registering and raises IntegrityError. How to bypass this and also keeping username unique? ie. no two users should have the same username. But username can be same as first_name. And two users can have same first_name, last_name. Yo

如何让django auth获取用户名和名字相同的值?

Django身份验证具有用户名和名称字段。 但是,用户名具有字段选项unique = True。 这可防止用户在注册时给first_name与用户名相同并引发IntegrityError。 如何绕过这一点,并保持用户名唯一? 即。 没有两个用户应该有相同的用户名。 但用户名可以与first_name相同。 并且两个用户可以具有相同的first_name,last_name。 你无法做到这一点。 如果您想在first_name和username字段中具有相同的值,并且其中一个值不唯一

how to override the verbose name of a superclass model field in django

Let's say that I have a model Foo that inherits from SuperFoo: class SuperFoo(models.Model): name = models.CharField('name of SuperFoo instance', max_length=50) ... class Foo(SuperFoo): ... # do something that changes verbose_name of name field of SuperFoo In class Foo, I'd like to override the verbose_name of the name field of SuperFoo. Can I? If not, is the best option

如何覆盖django中超类模型字段的详细名称

假设我有一个从SuperFoo继承的模型Foo: class SuperFoo(models.Model): name = models.CharField('name of SuperFoo instance', max_length=50) ... class Foo(SuperFoo): ... # do something that changes verbose_name of name field of SuperFoo 在Foo类中,我想覆盖SuperFoo的名称字段的verbose_name。 我可以吗? 如果不是,在模型表单定义中设置一个标签以将其显示在模板中是最佳选择吗? 我用过的简单

how to set a time out for SFTP server connection using paramiko?

I am struggling to set timeout option for SFTP connection using paramiko library. if i am moving 10GB file, after a period of time the process got stopped with out any error.There is no script issues. after I found the server got disconnected so only the file upload process not completed successfully. can any one know how to set timeout parameter using paramiko SFTP client.? script: s3_co

如何使用paramiko为SFTP服务器连接设置超时?

我很努力为使用paramiko库的SFTP连接设置超时选项。 如果我移动10GB文件,经过一段时间后,进程停止,没有任何错误。没有脚本问题。 在我发现服务器断开连接后,只有文件上传过程没有成功完成。 任何人都可以知道如何使用paramiko SFTP客户端设置超时参数。 脚本: s3_conn = S3Connection(profile_name=dest_profile) bucket = s3_conn.get_bucket(tgt_bucket_nm) proxy = paramiko.proxy.ProxyCommand('/usr/bin/nc --p

Python Paramiko deletes files on get or open

I am trying to use paramiko's SFTP module to read a file from a remote server but any time I call sftp.get('remote_filename', 'local_destination') It deletes 'remote_filename' from the server. I also tried getting the file object directly using sftp.file('remote_filename') but it still deletes the file after opening. Can anyone tell me why this might be happening? Here is an ex

Python Paramiko删除获取或打开文件

我试图使用paramiko的SFTP模块从远程服务器读取文件,但任何时候我打电话 sftp.get('remote_filename', 'local_destination') 它从服务器上删除'remote_filename'。 我也尝试直接使用文件对象 sftp.file('remote_filename') 但打开后仍然会删除文件。 谁能告诉我为什么会发生这种情况? 这是一个以文件名作为参数并返回SFTP File对象的示例函数: import paramiko, socks, os def get_file(filename): soc

Setting timelimit for sftp.get() of Paramiko module

I am using Paramiko's SFTP client to download a file from remote server to a client(ie get operation) The file to be transferred is a bit huge ~1GB. So I would like the get operation to timeout if the time is more than 10s. But setting the timeout value for connect doesn't work, It appears to be the timeout for just creating the SSH connection and not the timeout for the whole ssh c

为Paramiko模块的sftp.get()设置时间限制

我使用Paramiko的SFTP客户端从远程服务器下载文件到客户端(即获取操作) 要传输的文件有点巨大〜1GB。 所以,如果时间超过10秒,我希望get操作超时。 但是,为连接设置超时值不起作用,它似乎是创建SSH连接的超时时间,而不是整个ssh连接的超时时间。 ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host, username=username, password=password, timeout=10.0) sft

How to transfer a file to ssh server in an ssh

I am using Python's paramiko packet to keep an ssh-connection with an server : s = paramiko.SSHClient() s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) s.connect("xxx.xxx.xxx.xxx",22,username=xxx,password='',timeout=4) I want to use this ssh-connection to transfer a file to ssh server, how can i do? Just like use scp a-file xxx@xxx.xxx.xxx.xxx:filepath command? 尝试这个: s = par

如何在ssh中将文件传输到ssh服务器

我使用Python的paramiko数据包来保持与服务器的ssh连接: s = paramiko.SSHClient() s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) s.connect("xxx.xxx.xxx.xxx",22,username=xxx,password='',timeout=4) 我想用这个ssh-connection将文件传输到ssh服务器,我该怎么办? 就像使用scp a-file xxx@xxx.xxx.xxx.xxx:filepath命令一样? 尝试这个: s = paramiko.SSHClient() s.set_missing_host_key_policy(paramiko

Does paramiko close ssh connection on a non

I'm debugging some code, which is going to result in me constantly logging in / out of some external sftp servers. Does anyone know if paramiko automatically closes a ssh / sftp session on the external server if a non-paramiko exception is raised in the code? I can't find it in the docs and as the connections have to be made fairly early in each iteration I don't want to end up with

paramiko关闭SSH上的一个非连接

我正在调试一些代码,这将导致我不断登录/退出某些外部sftp服务器。 有谁知道如果paramiko自动关闭外部服务器上的ssh / sftp会话,如果在代码中引发了非paramiko异常? 我无法在文档中找到它,并且由于每次迭代都必须尽早完成连接,因此我不想以20个打开的连接结束连接。 不,paramiko不会自动关闭ssh / sftp会话。 如果例外由paramiko编码或其他方式产生,这并不重要; paramiko代码中没有捕获任何异常并自动关闭它们,所

How to send print job to printer in python

I used Tkinter to draw some lines in python and I would like to print that picture to usb connected and/or network printer in Windows. How should I do that? try this! It uses os module to start the file in the default printer! import os os.startfile("YourDocument", "print")

如何将打印作业发送到Python中的打印机

我用Tkinter在python中绘制一些线条,我想将该图片打印到Windows中的usb连接和/或网络打印机。 我应该怎么做? 尝试这个! 它使用os模块在默认打印机中启动文件! import os os.startfile("YourDocument", "print")