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

2016年4月21日 (木) 11:47時点における版

やりたいこと

手順

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 を作成

touch template/robots.txt

facebook slideshare rubygems github qiita