meeb/django-distill

Generate Sitemap

Closed this issue · 3 comments

i have set up a django project following the documentation on the django site.

Everything works great in my dev setup.

I use distill to output HTML for the pages in the site so i can upload to an SFTP that only serves static html files.

I've the basic django sitemap framework and it also works great and i can navigate to it in the browser, but when i distill:

i get this error:

CommandError: Failed to render view "/sitemap.xml": sitemap() missing 1 required positional argument: 'sitemaps'

Im pretty new at this stuff, but any help would be much appreciated!

meeb commented

Can you paste your sitemap view function, along with the distill_func for it form your views? Sounds like your URL requires an argument but your distill_func doesn't return one.

This is from my app level urls.py
`
info_dict = {
'queryset': Fet.objects.all().order_by('id'),
}

urlpatterns = [
distill_path("",views.index, name='home'),
distill_path("index.html",views.index, name='home'),
distill_path("gallery.html",views.gallery, name='gallery'),
distill_path("slug:slug.html",views.fet, name='fet_detail',distill_func=get_all_blogposts),
distill_path('sitemap.xml', sitemap, {'sitemaps': {'blog': GenericSitemap(info_dict, priority=0.6)}},
name='django.contrib.sitemaps.views.sitemap'),

]

`
There is no other code (other than installed_apps with: 'django.contrib.sitemaps', 'django.contrib.sites',) relating to sitemaps

meeb commented

This was caused by not fully passing through some rarely used manually coded positional arguments to path() which it seems is required by contrib.sitemaps to function. I introduced this bug when overriding the handlers to resolve #56. The commit above should resolve this issue to allow contrib.sitemaps views with their extra positional args for URLs (and any other views with extra args) to work as expected through distill. I've pushed this into a new 2.10.2 release just now, please update to 2.10.2 with pip or your preferred package manager and see if this has fixed it.