[Answered ]-How to extend the Django FlatPage view to include another context?

2👍

You’ve missed the point of the template tags advice. The point is not to pass images from the context into the tag, but the other way round: query the images in the tag and then pass them into the context from there.

The best way to do this is to use an inclusion tag rather than a simple tag: an inclusion tag is associated with its own template fragment which it renders with its own context, so you can include all elements related to your carousel there, and from the full flatpage template you only need to call the tag itself.

Although actually now I look at your question again, I realise that you don’t even need to do this. You have a foreign key from flatpage to image: you can get the images for a page with page.carouselimage_set.all. That makes the template tag irrelevant.

Leave a comment