I'm trying to pass a name attribute as a parameter in a function, to make it more generic.
For example, I'd like to modify this function:
@classmethod
def count_events_per_day(cls, myqueryset):
return myqueryset.filter(
created__range=(a,b))
to make something like:
@classmethod
def count_events_per_day(cls, myqueryset, attr_name): # attr_name would be passed as a string
return myqueryset.filter(
attr_name__range=(a,b))
Is there a way to do this? I searched on SO but I suppose the keywords I use are not relevants since I can't find any answer.
Thanks!