On Tuesday 11 December 2007 12:33:23 pm Greg wrote:
> Hello,
> I'm trying to get my RSS feed items to link to the right url, however
> I'm having trouble.  I was orginally having my blogs appear in my RSS
> feed.  When I clicked on one of them I would get the error:
>
> ' Invalid feed parameters. Slug u'latest' is valid, but other
> parameters, or lack thereof, are not. '
>
> However, after changing some of my code my blog entries are not even
> showing up in my RSS feed.  Here is what I have so far.
>
> ////////////////////////////
>
> urls.py
>
> from mysite.app.models import LatestEntries, LatestEntriesByCategory
>
> feeds = {
>     'latest': LatestEntries,
>     'categories': LatestEntriesByCategory,
> }
>
> urlpatterns = patterns('',
> (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
> {'feed_dict': feeds}),
> )
>
> ///////////////////////
>
> models.py
>
> from django.contrib.syndication.feeds import Feed
>
> class LatestEntries(Feed):
>     title = "MySite.com News"
>     link = "Not Sure what goes here"
>     description = "Updates on changes and additions to Mysite.com."
>
> class LatestEntriesByCategory(Feed):
>     def get_object(self, bits):
>         if len(bits) < 1:
>             raise ObjectDoesNotExist
>         return Blog.objects.get(slug=bits[-1])
>
>     def title(self, obj):
>         return "My blog for %s" % obj.name
>
>     def link(self, obj):
>         return obj.get_absolute_url()
>
>     def description(self, obj):
>         return "Blog entries recently posted in category %s" %
> obj.name
>
>     def items(self, obj):
>         return Blog.objects.filter(blogslug=obj.slug).order_by('-
> created_at')[:10]
>
> class Blog(models.Model):
>     title = models.CharField(maxlength=200)
>     blogslug = models.SlugField(prepopulate_from=["title"])
>     content = models.TextField(maxlength=5000)
>
>     def get_absolute_url(self):
>         return "/app/feeds/latest/%i/" % self.id
>

I ran into this recently, what's going on is the feed class is trying to find 
a blog slug object with get_object() that matches 'latest', when you define 
get_object().  If you use something like this with a valid slug, your feed 
will work fine.

http://mysite.com/feeds/latest/some-cool-blog-item/


Removing get_object() from the feed class, then it will work with this url:

http://mysite.com/feeds/latest/  

Mike


-- 
Apathy Club meeting this Friday.  If you want to come, you're not invited.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to