формируется sitemap.xml
This commit is contained in:
parent
3de50d551a
commit
6c506ed251
Binary file not shown.
@ -26,6 +26,7 @@ urlpatterns = [
|
|||||||
|
|
||||||
url(r'^$', views.index),
|
url(r'^$', views.index),
|
||||||
url(r'^(?P<dq_id>\d{1,12})_\S*$', views.by_id),
|
url(r'^(?P<dq_id>\d{1,12})_\S*$', views.by_id),
|
||||||
|
url(r'^sitemap.xml$', views.sitemap),
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
5
dicquo/templates/sitemap.xml
Normal file
5
dicquo/templates/sitemap.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
<url><loc>https://dq.cube2.ru/</loc><priority>0.1</priority></url>{% for I in DATA %}
|
||||||
|
<url><loc>https://dq.cube2.ru/{{ I.ID }}_{{ I.SLUG }}</loc><priority>1</priority></url>{% endfor %}
|
||||||
|
</urlset>
|
@ -33,7 +33,7 @@ def for_dq(dq):
|
|||||||
tags = dq.tags.names()
|
tags = dq.tags.names()
|
||||||
tag_and_slug = []
|
tag_and_slug = []
|
||||||
for i in tags:
|
for i in tags:
|
||||||
tag_and_slug.append({"name": i, "slug": pytils.translit.slugify(i.lower())[:128]})
|
tag_and_slug.append({"name": i, "slug": pytils.translit.slugify(i.lower())[:120]})
|
||||||
to_template.update({'TAGS': sorted(tag_and_slug, key=lambda x: x["name"])}) # tag_and_slug
|
to_template.update({'TAGS': sorted(tag_and_slug, key=lambda x: x["name"])}) # tag_and_slug
|
||||||
if dq.kImages_id is None:
|
if dq.kImages_id is None:
|
||||||
if len(tags) != 0:
|
if len(tags) != 0:
|
||||||
@ -87,3 +87,14 @@ def index(request):
|
|||||||
to_template.update({'ticks': float(time.process_time() - t_start)})
|
to_template.update({'ticks': float(time.process_time() - t_start)})
|
||||||
response = render(request, template, to_template)
|
response = render(request, template, to_template)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def sitemap(request):
|
||||||
|
template = "sitemap.xml" # шаблон
|
||||||
|
to_template = []
|
||||||
|
dq = TbDictumAndQuotes.objects.order_by('id').all()
|
||||||
|
for i in dq:
|
||||||
|
to_template.append({"ID": i.id,
|
||||||
|
"SLUG": pytils.translit.slugify(i.szContent.lower()[:120])})
|
||||||
|
response = render(request, template, {"DATA": to_template})
|
||||||
|
return response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user