在django模板中使用google表作为上下文变量
django-sheets的Python项目详细描述
在django模板中将google sheets用作上下文变量
用法
在您的模板中:
{% load sheets %} {% csv "1uPsdcGUnUsf3d2xGHRGUUb7_k5IQPtBvfQY61u8Z8wE" as data %} <table> <thead> <tr> {% for header in data.headers %} <th>{{ header }}</th> {% endfor %} </tr> </thead> <tbody> {% for row in data.rows %} <tr> {% for cell in row %} <td>{{ cell }}</td> {% endfor %} </tr> {% endfor %} </tbody> </table>
查看输出,您应该会看到
Origin (English) | Name (English) | Origin (Native) | Name (Native) |
Australia | Nicole Kidman | Australia | Nicole Kidman |
Austria | Johann Strauss | Österreich | Johann Strauß |
Belgium (Flemish) | Rene Magritte | België | René Magritte |
Belgium (French) | Rene Magritte | Belgique | René Magritte |
Belgium (German) | Rene Magritte | Belgien | René Magritte |
历史
0.1.2(2014-24-03)
- 为多页文档添加了gid参数
0.1.1(2014-22-01)
- 添加了.headers和.rows方法(别名为[0]和[1:])
0.1.0(2014-18-01)
- pypi上的第一个版本。