The server I'm posting ym data to doesn't seem to support format
call so I get the folowing error.
Use f-string instead of 'format' call for the functions below.
def write_xlsx_response(self, queryset):
response = HttpResponse(
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)
response["Content-Disposition"] = 'attachment; filename="{}.xlsx"'.format(
self.get_filename()
)
export_xlsx_assessment(queryset, response)
return response
def write_csv_response(self, queryset):
response = HttpResponse(content_type="application/CSV")
response["Content-Disposition"] = 'attachment; filename="{}.csv"'.format(
self.get_filename()
)
export_csv_assessment(queryset, response)
return response
Please how can I convert this to f-string.
Thanks
the syntax for f-strings and .format is basically the same, you just move the parameters to inside the string and add an f to the front
f'attachment; filename="{self.get_filename()}.csv"'