简体   繁体   中英

Django sitemap.xml. Why I am getting example.com in the file?

I generate sitemap.xml on the development server, but instead of 127.0.0.1 I get example.com in he URL. I have nowhere in the code reference to example.com.

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

What needs to be changed and where? Thank you

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')),
    )

Edit your site object from Django Admin

By default Django adds one record inside Site model which is example.com

Change it to your domain and/or IP

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM