forked from hacktoolkit/django-htk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemaps.py
34 lines (27 loc) · 863 Bytes
/
sitemaps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
from itertools import chain
# https://docs.djangoproject.com/en/1.8/ref/contrib/sitemaps/
class HtkBaseSitemap(Sitemap):
priority = 0.5
changefreq = 'daily'
def get_static_view_names(self):
static_view_names = []
return static_view_names
def get_model_instances(self):
model_instances = []
return model_instances
def items(self):
static_view_names = self.get_static_view_names()
model_instances = self.get_model_instances()
_items = list(chain(
static_view_names,
model_instances,
))
return _items
def location(self, obj):
if type(obj) == str:
path = reverse(obj)
else:
path = obj.get_absolute_url()
return path