Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以使用 robots.txt,也可以使用自定义 Django 中间件,但我想知道这是否可以在视图级别完成。
您可以使用以下代码段添加 noindex 标记:
from django.http import HttpResponse response = HttpResponse("Text only, please.", content_type="text/plain") response['X-Robots-Tag'] = 'noindex' return response