get data from model with field name in django
field_name = "is_staff"
user = User.objects.get(pk=0)
field_name_val = getattr(user, field_name)
Are there any code examples left?
New code examples in category Python
field_name = "is_staff"
user = User.objects.get(pk=0)
field_name_val = getattr(user, field_name)