0

The flatpage() view in Django's Flatpages app passes a single context item to templates, flatpage. I'd like to add more data to the context and the only way I can think of is to copy both the flatpage() and render_flatpage() functions from the original views.py into a new app. And then in my urls.py where I have this:

from django.contrib.flatpages import views
from django.urls import path

urlpatterns = [
    path("about/", views.flatpage, {"url": "/about/"}, name="about"),
]

instead import from myapp import views to use my new custom view.

Both of my copies of the functions would be exactly the same as originals, except render_flatpage() would add more context data.

This seems over the top, copying so much code unchanged. But I don't have a better idea.

I don't want to create a custom context_processor for this, because this context is specific to each Flatpage, and should not be used on on other pages.

Phil Gyford
  • 13,432
  • 14
  • 81
  • 143

0 Answers0