如何在Django中同时使用CustomUser模型和OpenID进行身份验证?

2024-04-19 10:59:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习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进行身份验证?你知道吗

任何帮助都将不胜感激。你知道吗


Tags: django用户from模型importauthidmodels