From cbb34190cf1b99dc74574ea04c293d2ffc09ce70 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Wed, 28 Aug 2024 21:52:22 +0200 Subject: [PATCH] Installation des outils pour filtrer les robots --- src/agenda_culturel/settings/base.py | 10 ++++++++++ .../templates/agenda_culturel/page.html | 1 + src/agenda_culturel/urls.py | 4 +++- src/requirements.txt | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/agenda_culturel/settings/base.py b/src/agenda_culturel/settings/base.py index 9319deb..cfbb978 100644 --- a/src/agenda_culturel/settings/base.py +++ b/src/agenda_culturel/settings/base.py @@ -33,6 +33,8 @@ else: INSTALLED_APPS = [ "django.contrib.admin", + "django.contrib.sitemaps", + "django.contrib.sites", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", @@ -49,8 +51,11 @@ INSTALLED_APPS = [ "recurrence", "location_field.apps.DefaultConfig", "django.contrib.postgres", + "robots", ] +SITE_ID = 1 + MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", @@ -229,3 +234,8 @@ LOCATION_FIELD = { "provider.openstreetmap.max_zoom": 18, "search.provider": "addok", } + +# stop robots + +ROBOTS_USE_SITEMAP = False + diff --git a/src/agenda_culturel/templates/agenda_culturel/page.html b/src/agenda_culturel/templates/agenda_culturel/page.html index 221e9df..20ee74f 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page.html +++ b/src/agenda_culturel/templates/agenda_culturel/page.html @@ -4,6 +4,7 @@ Pommes de lune — {% block title %}{% endblock %} + {% load static %} diff --git a/src/agenda_culturel/urls.py b/src/agenda_culturel/urls.py index ab8a303..5824b3f 100644 --- a/src/agenda_culturel/urls.py +++ b/src/agenda_culturel/urls.py @@ -2,7 +2,7 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns -from django.urls import path, include +from django.urls import path, include, re_path from django.views.i18n import JavaScriptCatalog @@ -171,6 +171,8 @@ urlpatterns = [ "ical", export_ical, name="export_ical"), + re_path(r'^robots\.txt', include('robots.urls')), + ] if settings.DEBUG: diff --git a/src/requirements.txt b/src/requirements.txt index 0907ae3..8d71e93 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -38,3 +38,4 @@ lxml==5.1.0 bbcode==1.1.0 json5==0.9.25 django-location-field==2.7.3 +django-robots==6.1