FlatPage plugin changes

I’m offering minor extensions to allow customizations of flat pages’ plugin.

At the moment, it’s impossible to pass any custom context to flat page templates.

It’s required to expose some pieces of internal code and make patches. For example, I had to use patched copies of views, urls and middleware to provide my context to templates.

I offer to add two settings’ variables:

  • FLATPAGE_CONTEXT_GETTER to pass a context to the template renderer via a getter.
  • FLATPAGE_DEFAULT_TEMPLATE to specify default flat page template (the only way to change the template currently is to specify it in the flatpage model, and for each particular page).

The pull request is here:

Hi @lilliputten,

new settings generally have a very low chance of getting added especially if there are other waays to achieve what you are trying to do.

When it comes to FLATPAGE_DEFAULT_TEMPLATE it is not clear to me which benefit this provides over simply overriding flatpages/default.html as needed on your site.

As for the extra context: If you need to change the context based on the flatpage I wonder if it wouldn’t make more sense to simply write your own view serving the flatpage (just my personal opinion)?.

Another way of customizing the context is with a context processor. You could write a processor function that checks if the request is for a flatpage URL or view, and if so, returns the necessary extra values. If the values are simple constants with no database queries, then no need for a flatpage check.

Ok, apparently, nobody needs it. It’s closed now.