I have a few flatpages in my app menu, so, my question is, how I’ll pass variables to my flatpages if i don’t have any view for flatpages?
here is my urls.py:
(r'',include('django.contrib.flatpages.urls')),
I dont have any view’s for any flatpages, so I dont know how I’ll pass variable to my flatpages, like news, etc for display news column…
There are two possibilities I can think of:
Write a Template Context Processor, which adds the latest news objects to the context. I found James Bennett’s tutorial helpful.
Write a custom template tag. James Bennett has a tutorial on this as well. I haven’t followed it, so I can’t guarantee it works with Django 1.x.
As an aside, when using flatpages, if you add
to your
MIDDLEWARE_CLASSESin settings.py, then you can remove the flatpages item from urls.py.