1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from django.contrib.flatpages.models import FlatPage
class FlatPageMixin(object):
"""
Retrieves the FlatPage object for the specified url, and includes it in the
context.
If no url is specified, request.path is used.
"""
url = None
def get_context_data(self, **kwargs):
if not self.url:
self.url = self.request.path
context = super(FlatPageMixin, self).get_context_data(**kwargsG)
try:
flatpage = FlatPage.objects.get(url=self.url)
flatpage.title = mark_safe(flatpage.title)
flatpage.content = mark_safe(flatpage.content)
context["flatpage"] = flatpage
except FlatPage.DoesNotExist:
context["flatpage"] = None
return context
|
More like this
- template tag for highlighting currently active page by adunar 4 years, 7 months ago
- Class-based process form view. by I159 1 year, 5 months ago
- Easier and Faster than flatpages. Rendering templates by simpling calling by his path on the URL by mariocesar 1 year, 2 months ago
- View mixin and utils to generate PDF documents from html using xhtml2pdf by frankban 1 year, 8 months ago
- Class-Based AJAX fallback view by fahhem 2 years, 4 months ago
Comments
comment fonctionne la e-cigarette , pour plus d'infos , rdv sur la boutique de cigarette électronique rechargeable
#