我正在使用 Django 站點地圖框架,我必須使用函式 get_absolute_url 在站點地圖中呈現站點 URL。但是,我遇到了一個問題,因為我的鏈接變成了:exampleio.io 而不是 example.io。
我在我的模型中的功能是:
def get_absolute_url(self):
return reverse('packages', args=[self.name])
我在 sitemap.py 中的功能
class ExampleSitemap(Sitemap):
protocol = "https"
changefreq = "weekly"
priority = 0.7
limit = 500
def items(self):
return Example.objects.all()
我越來越:
<sitemap>
<loc>http://exampleio.io/sitemap-examples.xml</loc>
</sitemap>
uj5u.com熱心網友回復:
檢查站點部分下的 django /admin。確保您的網站在此處正確命名。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/518175.html
