Flask 的 UserMixin 的 Django 等价物是什么?
What is the Django equivalence for Flask's UserMixin?
在 Flask 中有来自 flask-login
模块的 flask.ext.login.UserMixin
。
我试图寻找 Django 等价物,最接近 Flask 的 UserMixin
是 django.contrib.auth.models.User
来自
https://docs.djangoproject.com/en/1.9/ref/contrib/auth/
Django 是否等同于 Flask 的 UserMixin
?有什么区别?
在PyBossa, using Flask's UserMixin中继承了UserMixin添加了twitter/facebookoauth
,django.contrib.auth.models.User
是否可以继承和子类化做同样的事情?
确实如此。它是一个存储有关已登录用户信息的模型。一样的。
您可以扩展模型或完全替换它。
There are two ways to extend the default User model without substituting your own model. If the changes you need are purely behavioral, and don’t require any change to what is stored in the database, you can create a proxy model based on User. This allows for any of the features offered by proxy models including default ordering, custom managers, or custom model methods.
扩展模型:
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#extending-the-existing-user-model
替换用户模型:
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#substituting-a-custom-user-model
在 Flask 中有来自 flask-login
模块的 flask.ext.login.UserMixin
。
我试图寻找 Django 等价物,最接近 Flask 的 UserMixin
是 django.contrib.auth.models.User
来自
https://docs.djangoproject.com/en/1.9/ref/contrib/auth/
Django 是否等同于 Flask 的 UserMixin
?有什么区别?
在PyBossa, using Flask's UserMixin中继承了UserMixin添加了twitter/facebookoauth
,django.contrib.auth.models.User
是否可以继承和子类化做同样的事情?
确实如此。它是一个存储有关已登录用户信息的模型。一样的。
您可以扩展模型或完全替换它。
There are two ways to extend the default User model without substituting your own model. If the changes you need are purely behavioral, and don’t require any change to what is stored in the database, you can create a proxy model based on User. This allows for any of the features offered by proxy models including default ordering, custom managers, or custom model methods.
扩展模型:
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#extending-the-existing-user-model
替换用户模型:
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#substituting-a-custom-user-model