I have used RSS Feed with django,
I have refer the below link https://docs.djangoproject.com/en/dev/ref/contrib/syndication/
And properly created the RSS, but Now I want to add the favicon for the RSS feeds pages.
Can anybody suggest me?
Thanks.
My code is:
In feeds/feed.py
class LatestArticlesFeed(Feed):
title='News -RSS'
link='/' # URI of site
description='Latest Article Entries'
def get_object(self, request):
category_slug = request.GET.get('category_slug')
category = Category.objects.get(slug = category_slug)
def items(self, obj):
article_list = Article.objects.filter(category =obj)[:10]
return article_list
def item_title (self, item):
return item.headline
In urls.py
(r'^feeds/article/$', LatestArticlesFeed()),
Add this to your urls.py file:
(r'^favicon\.ico$',
'django.views.generic.simple.redirect_to',
{'url': '/media/favicon.ico'}),
If you're talking about a WebFaction Django install, you should be able to edit the .conf file in the apache2 directory in your app's directory and add a Redirect /favicon.ico http://example.com/static/favicon.ico
Note that you can also specify a favicon in the HTML:
<link rel="shortcut icon" href="http://example.com/myicon.ico" />
As of Django 1.5 simple views like from Plymorphin's answer don't exist anymore. Modern approach to do this is presented below.
Assuming you have your favicon with other static files at: your_app/static/favicon.ico you can add to main urls.py:
from django.contrib.staticfiles.templatetags import staticfiles
from django.views.generic import base
...
urlpatterns += patterns(
'',
url('^favicon\.ico$',
base.RedirectView.as_view(url=staticfiles.static('favicon.ico'))),
)
or extend existing patterns inline.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.