这是我目前提供 robots.txt 的方法
url(r'^robots\.txt/$', TemplateView.as_view(template_name='robots.txt',
content_type='text/plain')),
我不认为这是最好的方法。我认为如果它只是一个纯静态资源并静态服务会更好。但是我的 django 应用程序的结构方式是静态根目录和所有后续静态文件都位于
http://my.domain.com/static/stuff-here
有什么想法吗?我是 django 的业余爱好者,但是
TemplateView.as_view(template_name='robots.txt',
content_type='text/plain')
看起来比仅对我在 nginx 上提供的静态目录的静态调用更消耗资源。