开发者

Using StaticGenerator to generate static HTML from a Django project

I'm trying to generate static HTML for a site I've built in Django. What I've come up with so far is StaticGenerator. It looks to me like it should be similar to the example from the github page, but I have written the code below and it gives the error below.

Code:

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
os.environ["DJANGO_SETTINGS_MODULE"] = "site.settings"
quick_publish('/')

Error (edited for brevity):

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, p开发者_如何学Pythonath.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'


OK, upon going through your trace, I'm going to guess your settings.WEB_ROOT is a tuple.

Relevant lines:

# 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:]])
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜