What does it mean for an object to be unscriptable?

后端 未结 2 2030
北恋
北恋 2021-01-04 03:43

I don\'t know what\'s going on here... I just want to check the value of a model field and then update it accordingly... any help or insight is appreciated!

model:

2条回答
  •  天涯浪人
    2021-01-04 03:59

    Alternatively, you can use a string with getattr:

    getattr(user_profile, 'beta', False)
    

    False is the default value; which, in your case would work with checking if the value is set or not. I found this very helpful, so I thought I would post this solution, even though the question was asked years ago. :)

提交回复
热议问题