简体   繁体   English

用户数据未在管理面板和 forms django 中更新

[英]User data not updating in admin panel and forms django

When I try to update user data (in admin panel or form) it does nothing and give 0 errors.当我尝试更新用户数据(在管理面板或表单中)时,它什么也不做,并给出 0 个错误。 In the admin panel, it says it updated, but data stays the same.在管理面板中,它说它已更新,但数据保持不变。

Here's my model.py: https://pastecode.io/s/jx4jpt0x这是我的model.py:https://pastecode.io/s/jx4jpt0x

The problem is here:问题在这里:

def save(self, *args, **kwargs):
    if not self.pk:
        self.user_role = self.base_role
        return super().save(*args, **kwargs)

You should not modify the save method since this is not required.您不应修改save方法,因为这不是必需的。 You have already defined the user_role attribute with default value as base_role .您已经定义了默认值为base_roleuser_role属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM