views:

477

answers:

2

Hi guys, im asking again :), i like that!!! jeej, im learning Django :D

Well, i have a few flatpages in my app menu, so, my question is, how ill pass variables to my flatpages if i dont have any view for flatpages?

here my url.py

(r'',include('django.contrib.flatpages.urls')),

i dont have any view's for any flatpages, so i dont know how ill pass variable to my flatpages, like news, etc for display news column...

Thanks :)

+3  A: 

There are two possibilities I can think of:

  1. Write a Template Context Processor, which adds the latest news objects to the context. I found James Bennett's tutorial helpful.

  2. 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

'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'

to your MIDDLEWARE_CLASSES in settings.py, then you can remove the flatpages item from urls.py.

Alasdair
This tutorial from James Bennett is the best :D, pow solution, thanks
Asinox
Which tutorial did you use? Context Processor or Template Tag?
Alasdair
Hi Alasdir... Template Tag :)
Asinox