Serving robots.txt in django1.5
You could have served robots.txt in django<1.5 as follows :
url(r'^robots\.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}),
1.5 onwards, directtotemplate has been depricated, to directly serve it from urls.py use the following snippet:
from django.views.generic import TemplateView
url('^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
Written by Skate Hunbash
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#