13👍
✅
setattr is what you’re looking for.
In your case you could do something like this:
for attr, value in info.items():
setattr(me, attr, value)
9👍
Why not do the following:
info = {'first_name': 'Artur', 'last_name': 'Sapek'}
user = User(**info)
Of course if you are using contrib.auth
‘s User
model you’ll need to provide the required fields.
Source:stackexchange.com