Django

Code

Changeset 2766

Show
Ignore:
Timestamp:
04/28/06 00:05:56 (2 years ago)
Author:
adrian
Message:

magic-removal: Proofread docs/syndication_feeds.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/docs/syndication_feeds.txt

    r2700 r2766  
    9494 
    9595    from django.contrib.syndication.feeds import Feed 
    96     from django.models.chicagocrime import newsitems 
     96    from chicagocrime.models import NewsItem 
    9797 
    9898    class SiteNewsFeed(Feed): 
     
    102102 
    103103        def items(self): 
    104             return newsitems.get_list(order_by=('-pub_date',), limit=5) 
     104            return NewsItem.objects.order_by('-pub_date')[:5] 
    105105 
    106106Note: 
     
    177177            if len(bits) != 1: 
    178178                raise ObjectDoesNotExist 
    179             return beats.get_object(beat__exact=bits[0]) 
     179            return Beat.objects.get(beat__exact=bits[0]) 
    180180 
    181181        def title(self, obj): 
     
    189189 
    190190        def items(self, obj): 
    191             return crimes.get_list(beat__id__exact=obj.id, order_by=(('-crime_date'),), limit=30) 
     191            return Crime.objects.filter(beat__id__exact=obj.id).order_by('-crime_date')[:30] 
    192192 
    193193Here's the basic algorithm the RSS framework follows, given this class and a 
     
    205205      ``django.core.exceptions.ObjectDoesNotExist`` if given invalid 
    206206      parameters. There's no ``try``/``except`` around the 
    207       ``beats.get_object()`` call, because it's not necessary; that function 
    208       raises ``BeatDoesNotExist`` on failure, and ``BeatDoesNotExist`` is a 
     207      ``Beat.objects.get()`` call, because it's not necessary; that function 
     208      raises ``Beat.DoesNotExist`` on failure, and ``Beat.DoesNotExist`` is a 
    209209      subclass of ``ObjectDoesNotExist``. Raising ``ObjectDoesNotExist`` in 
    210210      ``get_object()`` tells Django to produce a 404 error for that request. 
     
    294294 
    295295    from django.contrib.syndication.feeds import Feed 
    296     from django.models.chicagocrime import newsitems 
     296    from chicagocrime.models import NewsItem 
    297297    from django.utils.feedgenerator import Atom1Feed 
    298298 
     
    303303 
    304304        def items(self): 
    305             return newsitems.get_list(order_by=('-pub_date',), limit=5) 
     305            return NewsItem.objects.order_by('-pub_date')[:5] 
    306306 
    307307    class AtomSiteNewsFeed(RssSiteNewsFeed): 
     
    329329 
    330330This example illustrates all possible attributes and methods for a ``Feed`` class:: 
    331  
    332331 
    333332    from django.contrib.syndication.feeds import Feed