【问题标题】:Django RSS feed showing IP in <link> instead of domainDjango RSS 提要在 <link> 而不是域中显示 IP
【发布时间】:2021-08-26 20:01:51
【问题描述】:

我有一个 Django 网站,最近我添加了 RSS 提要。我注意到生成的提要显示的是主机的 ip 而不是我的域:

<link>http://12.324.6.789/articles/</link>

下面是代码

from django.contrib.syndication.views import Feed 
from django.template.defaultfilters import truncatewords 
from django.urls import reverse 
from django.utils.feedgenerator import Atom1Feed 

class blogFeed(Feed): 
    title = "BLOGTITLE"
    link = "/articles/"
    description = "RSS feed of BLOG"

    def items(self): 
        return ArticlePage.objects.live().order_by('-date_display')[:10]

    def item_title(self, item): 
        return item.title 
        

    def item_link(self, item): 
        return item.full_url

还有这条路线

# RSS route   
    path("rss/", blogFeed(), name ="feed"), 

有什么建议吗?

【问题讨论】:

    标签: django rss wagtail


    【解决方案1】:

    我发现我缺少 django_site 表中的域, 所以我在另一个线程的回复之后将该域添加到我的列表中。

    然后我设置正确的 SITE_ID

    https://stackoverflow.com/a/21101910/11442007

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      • 2011-07-23
      • 1970-01-01
      • 2017-01-03
      • 2020-08-16
      相关资源
      最近更新 更多