我的views.py中包含以下内容:
ACCEPTED = ["x", "y", "z", ...]
def index(request, param):
if not (param in ACCEPTED):
raise Http404
return render(request, "index.html", {"param": param})
Url足够简单:
path('articles/<str:param>/', views.index, name='index'),
如何仅为ACCEPTED
常量中定义的参数生成此路径的站点Map?我所看到的示例通常是查询数据库以获取详细视图列表。
1条答案
按热度按时间3htmauhk1#
Django文档中有适合您的解决方案:https://docs.djangoproject.com/en/4.1/ref/contrib/sitemaps/#sitemap-for-static-views
对于您的页面,请执行以下操作: