my_dict['name'] = my_model.objects.get(pk=pk).object_name
I need ".object_name" to be a dynamic variable.
I tried creating a variable and adding it to the end.
my_model.objects.get(pk=pk).variable_name
my_model.objects.get(pk=pk)variable_name
etc...
When I try to add a variable to the end of the query it throws an error.
"Object has no attribute 'variable_name'".
"Statements must be separated by a new line or semicolon."
I'm sure there must be some other way to write this but I can't find any information to achieve this.