Dondariadmin (トーク | 投稿記録) (ページの作成:「== やりたいこと == * http://example.com/robots.txt アクセスに対してrobos.txtを正しく返す。 == 手順 == === app_dir/urls.py === from django.vie...」) |
Dondariadmin (トーク | 投稿記録) (→app_dir/urls.py) |
||
5行目: | 5行目: | ||
=== app_dir/urls.py === | === app_dir/urls.py === | ||
+ | * django.views.generic.TemplateView を使います | ||
− | + | from django.views.generic import TemplateView | |
− | + | ||
− | + | urlpatterns = [ | |
− | + | ... | |
+ | url(r'^robots\.txt', TemplateView.as_view(template_name='static/robots.txt', content_type='text/plain')), # <- append | ||
=== robots.txt を作成 === | === robots.txt を作成 === | ||
touch template/robots.txt | touch template/robots.txt |
from django.views.generic import TemplateView urlpatterns = [ ... url(r'^robots\.txt', TemplateView.as_view(template_name='static/robots.txt', content_type='text/plain')), # <- append
touch template/robots.txtTweet