31👍
✅
The error is “unSUBscriptable”. Your user_profile object isn’t a dictionary. Use user_profile.beta
, not user_profile['beta']
.
27👍
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. 🙂
0👍
Method One
model_name.object.filter(column_name='value').last
Method Two
This error happens when you tries to insert a model object in text filed
Source:stackexchange.com