Closed kirmola closed 1 year ago
Does your static
directory get generated correctly if you use the standard ./manage.py collectstatic
command?
Does your
static
directory get generated correctly if you use the standard./manage.py collectstatic
command?
Yes, this directory is generated correctly. Also, I am on the latest version of django. Is it possible that this is causing the issue
@meeb Looks like I've got a solution for where I was going wrong. I have had a sitemap url which was throwing an error. I am still unable to generate a sitemap though but now static files are properly being copied.
Only if you could give me solution for automatic sitemap generation...... It will be appreciated.
What error is being generated when you try and distill your sitemap?
Just this CommandError: Failed to render view "/sitemap.xml": sitemap.xml
This is sitemap url distill_path('sitemap.xml', views.sitemap, name='sitemap', distill_file="sitemap.xml"),
OK... that means that the "error" being raised is somehow "sitemap.xml" by your view, so I guess you have something weird in your views.sitemap
function?
I just used django's default sitemap framework and I don't know what is going on
There are tests in django-distill
that work and render a static sitemap. Take a look in https://github.com/meeb/django-distill/blob/0e6a4367063ce032546b34097e12095b3b519ff8/tests/urls.py for a working implementation example. It's pretty much just this (as an example, edit as needed):
from django.contrib.sitemaps import Sitemap
from django.contrib.sitemaps.views import sitemap
class SomeSitemap(Sitemap):
priority = 0.5
changefreq = 'daily'
def items(self):
return [some, iterable, of, objects]
def location(self, item):
return reverse(item)
sitemap_dict = {
'static': SomeSitemap,
}
urlpatterns = [
distill_path('sitemap.xml',
sitemap,
{'sitemaps': sitemap_dict},
name='sitemap'
)
]
This is documented thoroughly at https://docs.djangoproject.com/en/4.1/ref/contrib/sitemaps/
I don't think your sitemap is set up correctly at first glance.
I worked around some other solution other than django's default sitemap and got it working. Thankyou for your quick support
I am using latest version of django-distill. Whenever I use command:
python .\manage.py distill-local --force --collectstatic
, I can't see generated static folder. my static root settings.STATIC_ROOT = BASE_DIR/"static"
. What I want is the static folder to appear in folder setted inDISTILL_DIR
.