28 lines
970 B
Python
28 lines
970 B
Python
from django.core.management.base import BaseCommand
|
|
from django.contrib.sitemaps import Sitemap
|
|
from django.urls import reverse
|
|
from programmer.models import Home, Solution, Competence, Recall
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Test sitemap generation'
|
|
|
|
def handle(self, *args, **options):
|
|
from programmer.sitemaps import sitemaps
|
|
|
|
self.stdout.write('Testing sitemap generation...')
|
|
|
|
for name, sitemap in sitemaps.items():
|
|
self.stdout.write(f'\n{name}:')
|
|
items = sitemap().items()
|
|
self.stdout.write(f' Items found: {len(items)}')
|
|
|
|
for item in items[:3]: # Показываем первые 3 элемента
|
|
try:
|
|
url = sitemap().location(item)
|
|
self.stdout.write(f' - {url}')
|
|
except Exception as e:
|
|
self.stdout.write(f' - Error: {e}')
|
|
|
|
self.stdout.write('\nSitemap test completed!')
|