81👍
✅
If you modify the value via setattr
, you need to remember to save the model after modifying it. I’ve been bitten in the past where I changed the values but forgot to save the model, and got the same result.
setattr(f, 'bar', 'BAR')
f.save()
20👍
We may have to see more code.
setattr(f, 'bar', 'BAR')
should work as this is how Django does it internally.
Make sure you are calling ‘save’, as well.
- [Django]-How to use pdb.set_trace() in a Django unittest?
- [Django]-Django-nonrel + Django-registration problem: unexpected keyword argument 'uidb36' when resetting password
- [Django]-Django: How can I create a multiple select form?
Source:stackexchange.com