how to join list of objects with join method in python django
Caught an exception while rendering: sequence item 0: expected string, Contributor found
join menthod join list of stings, so we have to convert list of objets to list of strings.
solution:
Here 'contributors' is a list of objects
contributors = book.author.all()
format_contributor(contributors)
def format_contributor(contributors):
y = []
for x in contributors:
y.append(str(x))
return ";".join(y)
No comments:
Post a Comment