标签: python django
我有CustomUser类
class CustomUser(User): some_extra_field = models.CharField(max_length=30, blank=True)
现在在某些视图中我将User实例作为参数,在此视图中我想基于该参数创建CustomUser实例。
我应该这样做吗?
def view(user): custom_user = user custom_user.__class__ = CustomUser
答案 0 :(得分:0)
this question on extending the User Model有帮助吗?