且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Django中将用户配置文件添加到UserDetailsS​​erializer

更新时间:2023-12-06 16:10:46

文档,假定已经创建了用户个人资料,现在可以对其进行更新。您只需要一张支票

In the documentation it is assumed that userprofile was already created and now can be updated. You just need a check

# get and update user profile
    try:
        profile = instance.userprofile
    except UserProfile.DoesNotExist:
        profile = UserProfile()
    if profile_data and company_name: