Django: reverse lookup URL of feeds?

Posted by Santa on Stack Overflow See other posts from Stack Overflow or by Santa
Published on 2010-04-09T02:48:30Z Indexed on 2010/04/09 2:53 UTC
Read the original article Hit count: 496

I am having trouble doing a reverse URL lookup for Django-generated feeds.

I have the following setup in urls.py:

feeds = {
    'latest': LatestEntries,
}

urlpatterns = patterns('',
    # ...
    # enable feeds (RSS)
    url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
        {'feed_dict': feeds}, name='feeds_view'),
)

I have tried using the following template tag:

<a href="{% url feeds_view latest %}">RSS feeds</a>

But the resulting link is not what want (http://my.domain.com/feeds//). It should be http://my.domain.com/feeds/latest/.

For now, I am using a hack to generate the URL for the template:

<a href="http://{{ request.META.HTTP_HOST }}/feeds/latest">RSS feeds</a>

But, as you can see, it clearly is not DRY. Is there something I am missing?

© Stack Overflow or respective owner

Related posts about python

Related posts about django