python - djangoproject access fields of object dynamically -
Can someone help me?
I have a list of fields called 'allowed_fields' and I have an object named 'personal'.
allowed_fields is a personal sub set I now want to run this type of loop
in allowed_fields for the area:
obj.field = individual.field
Are fields similar to obj like a person, is there a solution to your problem? I am grateful to you
If each area
is actually a string, You can try the following.
The name of the field name
has been changed from field
to better me, it is better that it is a string.
for fieldname in allowed_fields: setattr (obj, field name, getattr (personal, fieldname))
Comments
Post a Comment