I would like to make a query to a Django Model, but I do not know the fields to retrieve in advance. If I happen to know them and their number, I would do
MyModel.objects.values('field1', 'field2')
Indeed, I noticed that the values method takes optional positional arguments, *fields, as specified in the API reference.
Therefore, I thought of making a function, which takes *fields arguments and then using such args for my query. The wrapper would look like this:
def get_values(self, *fields):
return MyModel.objects.values(fields)
However, I get an AttributeError: 'tuple' object has no attribute 'split' as the QuerySet API does not like my tuple. How could I work it out?