For model
class User(db.Model, BaseUser): name = CharField() phone = CharField() age = IntegerField() points = IntegerField()
and the list of fields lst = ['phone', 'name', 'points']
Is there any way to return your query to fields in lst ?
I can't find an example in docs , but it looks like Django ORM has something like ...get().values(lst) .
I tried passing the list as an argument to User.select() , but getting
TypeError: issubclass() arg 1 must be a class
I think I could do something like [getattr(obj, field) for field in lst] with the resulting object, but it seems like there should be a better way?
Refresh . Link to values in Django docs here .
source share