0

我在开发服务器上生成了 sitemap.xml,但是我在他的 URL 中得到了 example.com 而不是 127.0.0.1。我在对 example.com 的代码引用中没有任何位置。

-<urlset>
 -<url>
    <loc>http://example.com/xxxx/ABCDE/</loc>
 -</url>
-</urlset>

什么需要改变,在哪里?谢谢

urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.i18n import i18n_patterns
from django.contrib.sitemaps.views import sitemap
from ael.sitemaps import StaticViewSitemap, CrossRefTableSitemap
from ael import views as ael_views

from django.contrib.sitemaps import views as sitemaps_views
from django.views.decorators.cache import cache_page


sitemaps = {
    'static': StaticViewSitemap,
    'crossreftable': CrossRefTableSitemap,
}

urlpatterns = [
    path('admin/', admin.site.urls),
    path('i18n/', include('django.conf.urls.i18n')),

    path('sitemap.xml',
         cache_page(86400)(sitemaps_views.index),
         {'sitemaps': sitemaps, 'sitemap_url_name': 'sitemaps'}),
    path('sitemap-<section>.xml',
         cache_page(86400)(sitemaps_views.sitemap),
         {'sitemaps': sitemaps}, name='sitemaps'),

    path('start_page/', ael_views.start_page, name='start_page'),
    path('search_form/', ael_views.search_form, name = 'search_form'),
    path('smap_detail/<str:smapnr>/', ael_views.smap_detail, name = 'smap_detail'),
]

urlpatterns += i18n_patterns(
    path('ael/', include('ael.urls')),
    )
4

1 回答 1

1

编辑您的站点对象Django Admin

默认情况下会在其中Django添加一条记录Site modelexample.com

将其更改为您的domain and/or IP

于 2020-06-08T10:50:56.933 回答