This issue is somewhat selfish in nature. I prefer to use Function-Based Views, and would like to use WeasyTemplateResponse in these views with minimal boilerplate. Specifying content_type in the returned response should no longer be necessary.
As noted in the README, support for PNG output in Weasyprint has been removed, so we can default to using 'application/pdf' as the content_type for WeasyTemplateResponse.
Additionally, this can be done in an entirely backwards-compatible manner by setting the content_type in the init method of WeasyTemplateResponse, defaulting to a pdf if not otherwise set: self.content_type = kwargs.get("content_type", "application/pdf")
This issue is somewhat selfish in nature. I prefer to use Function-Based Views, and would like to use WeasyTemplateResponse in these views with minimal boilerplate. Specifying
content_type
in the returned response should no longer be necessary.As noted in the README, support for PNG output in Weasyprint has been removed, so we can default to using
'application/pdf'
as the content_type for WeasyTemplateResponse.Additionally, this can be done in an entirely backwards-compatible manner by setting the content_type in the init method of WeasyTemplateResponse, defaulting to a pdf if not otherwise set:
self.content_type = kwargs.get("content_type", "application/pdf")
Then all we need for a view is:
Would a PR with this small change and an example for the docs be helpful?