![](/img/trans.png)
[英]How to attach a python file to each row(i.e. each data entry) in database formed using Django?
[英]Export Django view to static HTML files using Django API (i.e. not wget or other scraper)
我有幾個Django視圖,我想將其導出為靜態HTML網站(托管在AWS S3上)。 該網站不使用任何身份驗證或動態功能,因此以靜態格式投放是理想的選擇。
使用Django StaticGenerator ( 原始源代碼 )或wget -m
似乎是一個很好的解決方案,但是它們需要我運行我的Web服務器(即使它碰巧是manage.py runserver
)。
我更喜歡使用Django API來檢索視圖的HTML。 例如:
request
對象; 最簡單的方法是使用Django 測試客戶端
>>> from django.test import Client
>>> c = Client()
>>> response = c.get('/')
>>> response.content
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.