Obtenga datos del modelo con nombre de campo en Django
field_name = "is_staff"
user = User.objects.get(pk=0)
field_name_val = getattr(user, field_name)
JThayil
field_name = "is_staff"
user = User.objects.get(pk=0)
field_name_val = getattr(user, field_name)
field_name = 'name'
obj = MyModel.objects.first()
field_object = MyModel._meta.get_field(field_name)
field_value = field_object.value_from_object(obj)