我正在学习pythondjango框架。多亏了StackOverFlow社区,我学会了如何在django中使用openid(我使用的是socialauth)。你知道吗
使用social\u auth,登录和注销过程非常简单实用。但是我想在用户之间建立友好关系,为此我创建了新的模型类,它是从from django.contrib.auth.models import User
扩展而来的,并且添加了控件当在auth\u表中创建新用户时,我在CustomUser表上创建了新用户(因为每个open id连接的open id参数不同,所以效率不高)
我的型号代码在这里
from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.models import UserManager
# Create your models here.
class CustomUser(User):
gender = models.CharField(max_length=50)
location = models.CharField(max_length=50)
bio = models.CharField(max_length=50)
web_pages = models.CharField(max_length=50)
friends = models.ManyToManyField("self")
如何在Django中同时使用CustomUser模型和OpenID进行身份验证?你知道吗
任何帮助都将不胜感激。你知道吗
在Django中扩展User类的方法是提供User profile类。见here。然后,您就可以一如既往地使用用户模型并按需获取概要文件实例。你知道吗
相关问题 更多 >
编程相关推荐