“Django google authenticator”与“Django model”:页面之间的差异

来自linuxsa wiki
(页面间差异)
跳转到导航 跳转到搜索
Evan留言 | 贡献
导入1个版本
 
Evan留言 | 贡献
 
第1行: 第1行:
=google-authenticator client=


==安装==
=Django model中的 class Meta 详解=


这个不用说啦  play 商店中 找 google 身份验证器.我的手机是android 7
<pre>


一般的样子
    class Meta:
        verbose_name = '项目管理 '
        verbose_name_plural = verbose_name


== config==
    def __str__(self):
添加 ==> 输入提供的密钥  记得要保存好你的密钥哦
        return f"{self.name}项目 "


解说


=google-authenticator server=
Model 元数据就是 "不是一个字段的任何数据" -- 比如排序选项, admin 选项等等.


=设想=
下面是所有可能用到的 Meta 选项. 没有一个选项是必需的. 是否添加 class Meta 到你的 model 完全是可选的.
可以加个不回显示的验证码,哈哈 笑死


=参考=


[http://jungor.me/?p=547  最好的可以直接代码之Django + Google Authenticator]


[https://medium.com/@jainsahil1997/simple-google-authentication-in-django-58101a34736b Simple Google Authentication in Django]


[https://zh.wikipedia.org/wiki/Google%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81%E5%99%A8 Google身份验证器]
verbose_name
verbose_name的意思很简单,就是给你的模型类起一个更可读的名字:


https://pypi.python.org/pypi/django-google-authenticator
verbose_name = "pizza"
若未提供该选项, Django 则会用一个类名字的 munged 版本来代替: CamelCase becomes camel case.


https://github.com/Bouke/django-two-factor-auth
verbose_name_plural
这个选项是指定,模型的复数形式是什么,比如:


verbose_name_plural = "stories"
若未提供该选项, Django 会使用 verbose_name + "s".




https://github.com/gnosis/django-google-authenticator
ordering
这个字段是告诉Django模型对象返回的记录结果集是按照哪个字段排序的。比如下面的代码:


ordering=['order_date']
# 按订单升序排列
ordering=['-order_date']
# 按订单降序排列,-表示降序
ordering=['?order_date']
# 随机排序,?表示随机
ordering = ['-pub_date', 'author']
# 对 pub_date 降序,然后对 author 升序


abstract


Options.abstract
如果 abstract = True, 就表示模型是 抽象基类 (abstract base class).


[https://www.jianshu.com/p/6c751ddbbc7c 谷歌身份验证使用教程及失效详解]


[https://help.aliyun.com/document_detail/28669.html 安卓版Google Authenticator安装及使用指导]
permissions
permissions主要是为了在Django Admin管理模块下使用的,如果你设置了这个属性可以让指定的方法权限描述更清晰可读。


[https://gadgets.ndtv.com/apps/features/google-authenticator-app-gmail-account-two-factor-security-1684339 How to Use Google Authenticator App to Secure Your Gmail Account ]
要创建一个对象所需要的额外的权限. 如果一个对象有 admin 设置, 则每个对象的添加,删除和改变权限会人(依据该选项)自动创建.下面这个例子指定了一个附加权限: can_deliver_pizzas:
[https://www.jianshu.com/p/5806ff9c0cc5 在Django中定制身份验证]


[https://support.google.com/accounts/troubleshooter/4430955?hl=zh-Hans#ts=4430956 google使用新手机接收两步验证码]
permissions = (("can_deliver_pizzas", "Can deliver pizzas"),)
这是一个2-元素 tuple 的tuple或列表, 其中两2-元素 tuple 的格式为:(permission_code, human_readable_permission_name).


[https://www.google.com/landing/2step/#tab=how-it-works 增强 Google 帐户的安全性]


[https://www.howtoing.com/secure-ssh-with-google-authenticator-on-centos-7 CentOS 7上使用Google Authenticator双重身份验证保护SSH安全]
</pre>


[https://www.freehao123.com/two-factor-authentication/ WordPress和VPS利用Google Authenticator两步验证]
=django models def __str__(self)=
<pre>
建议先看
https://segmentfault.com/q/1010000006121303
def __str__(self):
        """将模型类以字符串的方式输出"""
        return self.name


[https://django-two-factor-auth.readthedocs.io/en/stable/index.html Django Two-Factor Authentication Documentation]
举例子 只写模型类、不写__str__的时候
只写模型类、不写__str__的时候
class BookInfo(models.Model):
    # 创建字段,字段类型...
    name = models.CharField(max_length=10)


[https://teakki.com/p/5929371e6e5c97852743d7e7 在Django中自定义身份验证]
写__str__ 显示为中文str 等等
 


class BookInfo(models.Model):
    # 创建字段,字段类型...
    name = models.CharField(max_length=10)
    def __str__(self):
    #    """将模型类以字符串的方式输出"""
        return self.name


</pre>


https://segmentfault.com/q/1010000006121303


== github上的GoogleAuthenticator ==
[https://blog.csdn.net/wyongkang/article/details/116229846 django models def __str__(self)]


https://github.com/collective/collective.googleauthenticator
[https://blog.csdn.net/qq_43697400/article/details/86498546 Django模型类的补充__str__方法]


https://github.com/shinsaka/googleauthenticator_demo
[https://www.zhihu.com/question/273973677 Django models def __str__(self)有什么作用?]


https://github.com/cqf539/GoogleAuthenticator
=see also=
[https://www.cnblogs.com/tongchengbin/p/7670927.html Django model中的 class Meta 详解]


https://github.com/gnosis/django-google-authenticator
[https://blog.csdn.net/Moniicoo/article/details/81781572 Django模型类Meta元数据详解(class Meta: )]


==google 验证 ==
[https://blog.csdn.net/qq_41763291/article/details/80229977 goodDay47-Django中的class Meta知识点]


[http://www.williamlong.info/archives/2754.html Google两步验证安装使用方法]
[[category:django]]
 
[https://www.zhihu.com/question/20462696 谷歌验证 (Google Authenticator) 的实现原理]
 
[[category:django]]

2021年6月12日 (六) 06:38的最新版本

Django model中的 class Meta 详解

一般的样子
    class Meta:
        verbose_name = '项目管理 '
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"{self.name}项目 "

解说

Model 元数据就是 "不是一个字段的任何数据" -- 比如排序选项, admin 选项等等.

下面是所有可能用到的 Meta 选项. 没有一个选项是必需的. 是否添加 class Meta 到你的 model 完全是可选的.




verbose_name
verbose_name的意思很简单,就是给你的模型类起一个更可读的名字:

verbose_name = "pizza"
若未提供该选项, Django 则会用一个类名字的 munged 版本来代替: CamelCase becomes camel case.

verbose_name_plural
这个选项是指定,模型的复数形式是什么,比如:

verbose_name_plural = "stories"
若未提供该选项, Django 会使用 verbose_name + "s".


ordering
这个字段是告诉Django模型对象返回的记录结果集是按照哪个字段排序的。比如下面的代码:

ordering=['order_date'] 
# 按订单升序排列
ordering=['-order_date'] 
# 按订单降序排列,-表示降序
ordering=['?order_date'] 
# 随机排序,?表示随机
ordering = ['-pub_date', 'author']
# 对 pub_date 降序,然后对 author 升序

abstract

Options.abstract
如果 abstract = True, 就表示模型是 抽象基类 (abstract base class).


permissions
permissions主要是为了在Django Admin管理模块下使用的,如果你设置了这个属性可以让指定的方法权限描述更清晰可读。

要创建一个对象所需要的额外的权限. 如果一个对象有 admin 设置, 则每个对象的添加,删除和改变权限会人(依据该选项)自动创建.下面这个例子指定了一个附加权限: can_deliver_pizzas:

permissions = (("can_deliver_pizzas", "Can deliver pizzas"),)
这是一个2-元素 tuple 的tuple或列表, 其中两2-元素 tuple 的格式为:(permission_code, human_readable_permission_name).


django models def __str__(self)

建议先看
https://segmentfault.com/q/1010000006121303
 def __str__(self):
        """将模型类以字符串的方式输出"""
        return self.name

举例子 只写模型类、不写__str__的时候
只写模型类、不写__str__的时候
class BookInfo(models.Model):
    # 创建字段,字段类型...
    name = models.CharField(max_length=10)

写__str__ 显示为中文str 等等
 

class BookInfo(models.Model):
    # 创建字段,字段类型...
    name = models.CharField(max_length=10)
     def __str__(self):
     #    """将模型类以字符串的方式输出"""
         return self.name

https://segmentfault.com/q/1010000006121303

django models def __str__(self)

Django模型类的补充__str__方法

Django models def __str__(self)有什么作用?

see also

Django model中的 class Meta 详解

Django模型类Meta元数据详解(class Meta: )

goodDay47-Django中的class Meta知识点