gpt4 book ai didi

python - django:尝试访问我的 robots.txt: "TypeError at/robots.txt ' str'对象不可调用”

转载 作者:行者123 更新时间:2023-12-01 06:15:10 24 4
gpt4 key购买 nike

异常类型:/robots.txt 处的 TypeError

异常值:“str”对象不可调用

什么给出了?

浏览次数:

ROBOTS_PATH = os.path.join(CURRENT_PATH, 'robots.txt')


def robots(request):
""" view for robots.txt file """
return HttpResponse(open(ROBOTS_PATH).read(), 'text/plain')

设置:

CURRENT_PATH = os.path.abspath(os.path.dirname(__file__).decode('utf-8'))

网址:

(r'^robots\.txt$', 'robots'),

最佳答案

尝试:

from appname.views import robots
(r'^robots\.txt$', robots),

或者:

(r'^robots\.txt$', 'projectname.appname.views.robots'),

Django 无法确定您的 'robots' 函数在哪里。

关于python - django:尝试访问我的 robots.txt: "TypeError at/robots.txt ' str'对象不可调用”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3640478/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com