I am using python, Django and get the following error:
getattr(): attribute name must be string
location: val = getattr(obj, field)
if field in headers:
if not isinstance(field, str):
val = getattr(obj, field)
else:
val = getattr(obj, field.LastName)
if callable(val):
val = val()
if type(val) == unicode:
val = val.encode("utf-8")
row.append(val)
I have tried many variation of code but all failed.
getattr(obj, field)after testing thatfieldis not a string. What did you expect to happen?