开发者

django: trying to access my robots.txt: "TypeError at /robots.txt 'str' object is not callable"

开发者 https://www.devze.com 2023-01-14 23:52 出处:网络
Exception Type: TypeError at /robots.txt Exception Value: \'str\' object is not callable What gives? Views:

Exception Type: TypeError at /robots.txt

Exception Value: 'str' object is not callable

What gives?

Views:

ROBOTS_PATH = os.path.join(CURRENT_PATH, 'ro开发者_C百科bots.txt')


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

Settings:

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

URLs:

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


Try:

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

Or:

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

Django can't figure out where your 'robots' function is.

0

精彩评论

暂无评论...
验证码 换一张
取 消