I've seen other answers here, but they aren't really helpful, which is why I am asking. I tried the django-robots framework as well, but it gives me an error when i just put 'robots' in my INSTALLED_APPS
INSTALLED_APPS = [
'index.apps.IndexConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
]
You can use simply use a TemplateView
User-agent: *
Disallow: /admin/
Disallow: /accounts/
from django.views.generic import TemplateView
urlpatterns = [
# ...
path('robots.txt', TemplateView.as_view(template_name="robots.txt", content_type='text/plain')),
# ...
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With