meeb / django-distill

Minimal configuration static site generator for Django
MIT License
441 stars 35 forks source link

Feature reuest: Option to ignore render errors #37

Closed henhuy closed 3 years ago

henhuy commented 3 years ago

For me it would be nice to add option to ignore non-200 errors on rendering pages. I have a view which is filled with many parameters, but not all pages return status 200 (but 204 instead). For me it would be nice to add option ignore_errors (default False) to distill_path. Will also provide PR if this is interesting for others too.

meeb commented 3 years ago

Hi, sorry for the delay in responding to your raised issues. I have no real objection to allowing 204 status codes to render but I'm mostly curious what's the use case for writing an empty file as part of a static site? I assume you just mean 204 status codes, allowing general render errors might be a bit weird if you write pages with 500 error page content HTML or static traces as static pages (if DEBUG is enabled) without raising errors is probably not that useful even with a settable flag defaulting to the current behaviour.

meeb commented 3 years ago

OK read up on with your PR #38 - I don't think it's a good idea to ignore all rendering errors with a blanket ignore, however I can see how you might want to render HTML content where the view returns a non-200 status code. I've added a distill_status_codes parameter to the distill_path(...) method which allows you to specify a tuple of status codes like (200, 204, 404) that a view may return and still be rendered by django-distill. I'll close this issue with that commit. Re-open this if this doesn't do what you need for some reason. Thanks for the suggestion and contributions to the project!