Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix robots view #474

Merged
merged 1 commit into from
Oct 21, 2024
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
4 changes: 2 additions & 2 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.conf import settings
from django.contrib.sitemaps.views import sitemap
from django.contrib.staticfiles.views import serve
from django.urls import include, path
from django.views.i18n import JavaScriptCatalog

from contributors.admin.custom import site
from contributors.sitemap import sitemaps
from contributors.views import robots


def trigger_error(request):
Expand All @@ -21,7 +21,7 @@ def trigger_error(request):
path('auth/', include('auth.urls')),
path('', include('contributors.urls')),
path('sentry-debug/', trigger_error),
path('robots.txt', serve, {'path': 'robots.txt'}),
path('robots.txt', robots.RobotsTxtView.as_view(), name='robots_txt'),
path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
]
Expand Down
16 changes: 16 additions & 0 deletions contributors/views/robots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.http import HttpResponse
from django.template import loader
from django.views.generic import TemplateView


class RobotsTxtView(TemplateView):
template_name = "robots.txt"
content_type = "text/plain"

def render_to_response(self, context, **response_kwargs):
template = loader.get_template(self.template_name)
response = HttpResponse(
template.render(context, self.request),
content_type=self.content_type
)
return response
File renamed without changes.
Loading