Не работает robots.txt на Django
У меня проблема с robots.txt, на локальном запуске всё нормально открывается, но после деплоя на хостинг /robots.txt перестал работать, а остальные /polls и /admin работают отлично
Page not found (404)
Request Method: GET
Request URL: http://username.pythonanywhere.com/robots.txt/
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
polls/
admin/
robots.txt
The current path, robots.txt/, didn’t match any of these.
Вот код в urls.py:
from django.contrib import admin
from django.urls import include, path
from django.views.generic.base import TemplateView
from robots.views import robots_txt
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
path("robots.txt", robots_txt),
]
И вот ещё robots/views.py:
from django.views.decorators.http import require_GET
from django.http import HttpResponse
@require_GET
def robots_txt(request):
lines = [
"User-Agent: Googlebot",
"Disallow: /polls/",
]
return HttpResponse("\n".join(lines), content_type="text/plain")```