Hi, how can I get a list of all flatpage objects in a template ?
I am not using development version ..
Thanks
Hi, how can I get a list of all flatpage objects in a template ?
I am not using development version ..
Thanks
The development version uses a custom template tag to get all the flatpage objects in a template. If you want this feature right away you should be able to copy the source code and add it as a custom tag.
Caveat: haven't tested this.
If you have access to the view that renders the template you want, you can pull all the flatpages from the database. Here's a REALLY crude and far-from-ideal solution:
In the view:
from django.contrib.flatpages.models import Flatpage
...do your other view stuff
flatpages = Flatpage.objects.all()
# You REALLY SHOULD filter() based on other properties of the Flatpages,
# such as whether or not it requires login to view, or, importantly,
# which Site it is available on (because not all Flatpages will
# necessarily be available on the current Site)
...then pass the flatpages queryset into your view
In your template:
<ul>
{% for flatpage in flatpages %}
<li><a href="{{flatpage.url}}">{{flatpage.title}}</a></li>
{#Note that the page title may not be good link text #}
{% endfor %}
</ul>