get data from model with field name in django

Solutions on MaxInterview for get data from model with field name in django by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "get data from model with field name in django"
Giovanni
06 Jul 2020
1field_name = "is_staff"
2user = User.objects.get(pk=0)
3field_name_val = getattr(user, field_name)