mirror of https://github.com/django/django.git
Fixed #19306 - Improved syndication example.
Thanks brycenesbitt for the report.
This commit is contained in:
parent
2564e31014
commit
1f1f60d12f
|
@ -53,6 +53,7 @@ This simple example, taken from `chicagocrime.org`_, describes a feed of the
|
||||||
latest five news items::
|
latest five news items::
|
||||||
|
|
||||||
from django.contrib.syndication.views import Feed
|
from django.contrib.syndication.views import Feed
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
from chicagocrime.models import NewsItem
|
from chicagocrime.models import NewsItem
|
||||||
|
|
||||||
class LatestEntriesFeed(Feed):
|
class LatestEntriesFeed(Feed):
|
||||||
|
@ -69,6 +70,10 @@ latest five news items::
|
||||||
def item_description(self, item):
|
def item_description(self, item):
|
||||||
return item.description
|
return item.description
|
||||||
|
|
||||||
|
# item_link is only needed if NewsItem has no get_absolute_url method.
|
||||||
|
def item_link(self, item):
|
||||||
|
return reverse('news-item', args=[item.pk])
|
||||||
|
|
||||||
To connect a URL to this feed, put an instance of the Feed object in
|
To connect a URL to this feed, put an instance of the Feed object in
|
||||||
your :doc:`URLconf </topics/http/urls>`. For example::
|
your :doc:`URLconf </topics/http/urls>`. For example::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue