I use something like this:
(r'^robots.txt$', 'django.views.static.serve', { 'path' : "/
txt/robots.txt",
'document_root': settings.MEDIA_ROOT,
'show_indexes': False } ),
On Feb 14, 10:53 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I built a Django site for my blog and want to serve a robots.txt file
> for it. But I can't figure out how to go about doing this since it's a
> static file.
>
> Here is what I have in my urls:
>
> from patrickbeeson.views import robots
> ...
> (r'^robots.txt$', robots),
>
> From the views:
>
> from django.http import HttpResponse
> from django.template import TemplateDoesNotExist
>
> def robots(request):
> try:
> return HttpResponse(open('robots.txt').read(), 'text/plain')
> except TemplateDoesNotExist:
> raise Http404()
>
> The "robots.txt" file is located in my templates directory with other
> templates.
>
> Any suggestions on what I might be doing wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---