Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
str(ROOT_DIR / "grumpy/core/templates"),
str(ROOT_DIR / "config/templates"),
],
# 'APP_DIRS': True, # not needed since "app_directories.Loader" is specified below
"OPTIONS": {
Expand Down
4 changes: 4 additions & 0 deletions config/templates/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# robots.txt

User-Agent: *
Disallow: /
6 changes: 6 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.generic import TemplateView

# from allauth.account.decorators import secure_admin_login

Expand Down Expand Up @@ -48,6 +49,11 @@
#################

urlpatterns = [
# robots.txt
path(
"robots.txt",
TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
),
# admin...
path("admin/", admin.site.urls),
# auth...
Expand Down
8 changes: 8 additions & 0 deletions grumpy/core/tests/test_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from http import HTTPStatus

def test_robots_txt(client):

response = client.get("/robots.txt")
assert response.status_code == HTTPStatus.OK
assert response["content-type"] == "text/plain"
assert response.content.startswith(b"# robots.txt\n")