|
Zamtools-news is a simple Django application for generating a single news feed. It has been kept intentionally spartan and is intended to be used for delivering site news or updates. Benefits- Bare bones approach
- RSS Support
- Custom views that mimic generic view contexts, but return more consistently named variables
- Ready-made templates
- Markup support
- Tests included
InstallationAdd zamtools-news to your project directory or put it somewhere on the PYTHONPATH. You can also use easy_install. > easy_install zamtools-news In your settings.py file, add zamtools-news to the INSTALLED_APPS. INSTALLED_APPS = (
'news',
) Optionally define the following settings in your settings.py file. NEWS_NUM_RECENT = 10
NEWS_PAGE_SIZE = 10
NEWS_FEED_TITLE = 'Recent Articles'
NEWS_FEED_DESCRIPTION = 'Recent Articles'
NEWS_FEED_LINK = '/news/' Synchronize your database. > python manage.py syncdb Configure your urls.py to include the news urls. urlpatterns = patterns('',
(r'^news/', include('news.urls')),
)UsageLog in to the Admin panel and create an article. The following urls are all accepted by zamtools-news. | /news/ | Return the most recent articles | | /news/2009/ | Return all articles for the supplied year, page the results | | /news/2009/5/ | Return all the articles for the supplied year and month, page the results | | /news/2009/5/10/ | Return all the articles for the supplied year, month and day, page the results | | /news/2009/5/10/some-article-slug/ | Return the exact specified article by year, month, day and slug | | /news/feeds/recent/ | Returns recent articles as an RSS feed |
Zamtools-news comes with a set of ready-made templates. The urls.py included in the application will use these templates by default. These templates can be overridden by creating any of the following files in the /project/templates/news/ directory. - /project
- /templates
- /news
- article.html (include file used for rendering the article across all templates)
- paginator.html (include file used for rendering the pages portion of the paginator across all pages)
- article_base.html
- article_archive.html
- article_archive_day.html
- article_archive_month.html
- article_archive_year.html
- article_detail.html
Additionally, feed templates can be overriden by creating any of the following files in the /project/templates/feeds/ directory. - /project
- /templates
- /feeds
- title.html
- description.html
Advanced UsageThe model has several convenient managers on it. The public manager retrieves only public articles that have their is_public field set to True. Article.public.all() The recent manager retrieves recent public articles. The number of recent articles that are retrieved depends on the NEWS_NUM_RECENT setting. If this variable isn't set, the default is 10. Article.recent.all() TestingTests can be performed using the standard Django test command. > python manage.py test news
|