我正在尝试为我在Django中构建的网站生成静态HTML。到目前为止我提出的是StaticGenerator。它看起来像它应该类似于github页面中的示例,但我已经编写了下面的代码,它给出了下面的错误。
代码:
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
os.environ["DJANGO_SETTINGS_MODULE"] = "site.settings"
quick_publish('/')
错误(为简洁起见编辑):
Traceback (most recent call last):
quick_publish('/')
File "/usr/local/lib/python2.6/dist-packages/staticgenerator/__init__.py", line 232, in quick_publish
return StaticGenerator(*resources).publish()
File "/dist-packages/staticgenerator/__init__.py", line 229, in publish
return self.do_all(self.publish_from_path)
File "/dist-packages/staticgenerator/__init__.py", line 223, in do_all
return [func(path) for path in self.resources]
File "/dist-packages/staticgenerator/__init__.py", line 187, in publish_from_path
filename, directory = self.get_filename_from_path(path)
File "/dist-packages/staticgenerator/__init__.py", line 179, in get_filename_from_path
filename = self.fs.join(self.web_root, path.lstrip('/')).encode('utf-8')
File "/dist-packages/staticgenerator/filesystem.py", line 38, in join
return os.path.join(paths[0], *[path.lstrip("/") for path in paths[1:]])
File "/usr/lib/python2.6/posixpath.py", line 67, in join
elif path == '' or path.endswith('/'):
AttributeError: 'tuple' object has no attribute 'endswith'
答案 0 :(得分:1)
好的,经过你的追踪,我猜你的settings.WEB_ROOT
是一个元组。
相关专栏:
# web root set
self.web_root = getattr(self.settings, 'WEB_ROOT')
# web root used
filename = self.fs.join(self.web_root, path.lstrip('/')).encode('utf-8')
# breaks on real os.path.join
return os.path.join(paths[0], *[path.lstrip("/") for path in paths[1:]])