失礼します。
Django2でfrom django.contrib.syndication.views import FeedをインポートしてFeedページを作っているのですが、
Feedのitemタグ内にimgタグを追加したいです。
python
1from django.contrib.syndication.views import Feed 2from django.utils.feedgenerator import Rss201rev2Feed, rfc2822_date 3from django.shortcuts import resolve_url 4from .models import Movie 5from django.urls import reverse_lazy 6 7 8class LatestPostFeed(Feed): 9 title = "サンプルサイト" 10 link = reverse_lazy('video:feed') 11 description = "サンプルサイトから、記事の最新情報をお届けします。" 12 13 def items(self): 14 return Movie.objects.all().order_by('-created_at') 15 16 def item_title(self, item): 17 return item.title 18 19 def item_description(self, item): 20 return item.thumb.url 21 22 def item_link(self, item): 23 return resolve_url('video:movie', pk=item.pk) 24 25 def item_categories(self, item): 26 return item.tag.split(',') 27 28 def item_pubdate(self, item): 29 return item.created_at
現在のコードは上記なのですが、Feedクラスにはitemタグごとにimgタグを挿入するメソッドが用意されていないようです。
python
1def item_description(self, item): 2 return '<img src="' + item.thumb.url + '">'
そのため上記のようにしたのですが、やはり**<>**など、htmlのタグがエスケープされてしまいます。
ネットで調べてもぜんぜん情報がのってなくて、正直どうすればいいのかわかりません。
どうもRss201rev2Feedクラスからさかのぼっていかないといけないようなのですが、ぼくには難しくてできませんでした。
どうすればいいですか?ご教授いただきたいです。
あなたの回答
tips
プレビュー