Answer the question
In order to leave comments, you need to log in
How to open html file in google docs?
There is a logic that generates the final document depending on the transferred file format (html, json, docx)
class CvView(AuthorizedMixin, View):
"""Employee CV view."""
def get(self, request, employee_id, format_):
"""Returns employee's CV in format which is equal to `format_`
parameter."""
employee = get_object_or_404(Employee, pk=employee_id)
user = request.user
content_type, data = Cv(employee, format_, user).get()
if isinstance(data, BytesIO):
return FileResponse(
data, as_attachment=True, filename=f'cv.{format_}',
content_type=content_type)
return HttpResponse(data, content_type=content_type)
return HttpResponse(data, content_type=content_type)
contains the html code of the template that opens on a new browser page according to the urlpath('cv/<int:employee_id>/<str:format_>/', CvView.as_view(), name='cv'),
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question