Sometimes I end up using Django for the wrong thing, just to dispatch pages and put all my content in the templates. Flatpages are too flat and other DB based content tools are too complex. I just want to use the dispatcher, and the templates (I know, I could use web.py, or whatever other Python tool).
So, In order to save myself some time, I made cheap_pages.py
, which is a wrapper for the patterns()
method that will populate it with direct_to_template calls.
So instead of doing this:
>>> url(^name/$,
... direct_to_template,
... {'template': 'name.html'},
... name='name')
I can do this:
Or instead of this:
urlpatterns = patterns('',
url(^pages/page1/$,
direct_to_template,
{'template': 'page1.html'},
name='page1')
url(^pages/page2/$,
direct_to_template,
{'template': 'page2.html'},
name='page2')
url(^pages/page3/$,
direct_to_template,
{'template': 'page3.html'},
name='page3')
)
I can do this:
I've added the file to Google Code under Django-cheap-pages, in case anyone is interested in improving it :) .