I did this long time ago and here is what i did... in settings.py SITE_ID = 1 # Application definition INSTALLED_APPS = [ # ... 'django.contrib.sites', 'django.contrib.sitemaps', ]
run migration i.e. >>> py manage.py migrate OR python manage.py migrate after this step, sites application will be in sync with the database. create a file sitemaps.py in your blog application. Your sitemap.py seems okay to me. update your main project urls.py file .... from django.contrib.sitemaps.views import sitemap from blog.sitemaps import BlogPostsSitemap sitemaps = { 'posts' : BlogPostsSitemap, } urlpatterns = [ .... path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] Now run the development server and open (assuming you are using default configuration) http://127.0.0.1:8000/sitemap lets try... On Tuesday, September 8, 2020 at 2:53:12 PM UTC-4 hanz...@gmail.com wrote: > I followed a tutorial for creating django sitemap, but still got problems > along the way. > I've seen some videos, but didn't work. > Do you have any references for easy way creating django sitemap for blog > posts? > Sure it would help. > > Thanks > > > > On Wed, Sep 9, 2020 at 12:02 AM coolguy <cooldjango...@gmail.com> wrote: > >> Not sure why you are importing this into your main project urls.py but >> its very straight forward >> >> from blog.sitemaps import BlogPostsSitemap >> >> question... are you trying to map the application url here? then you >> should use path('xxxx/' , Include("blog.urls")) >> >> >> >> >> On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com >> wrote: >> >>> Sorry, point no 1 needs to be revised.. >>> 1. In urls.py, I want to import BlogPostsSitemap >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%40googlegroups.com.