我在Django中準備了一個基本聯繫表單。數據成功保存。但我想檢索保存的數據(所有數據庫列)作爲一個HTML表格,並顯示在我的網站(不在管理界面)。檢索並渲染通過Django表單提交的數據API
這裏是模型:
class ContactForm(forms.Form):
name = forms.CharField(label='Your name')
place = forms.CharField(max_length=100,label='Your place')
message = forms.CharField(label='Your message')
url = forms.URLField(label='Your Web site', required=False)
options = forms.BooleanField(required=False)
day = forms.DateField(initial=datetime.date.today)
的觀點僅接受POST數據並重定向到一個「謝謝」頁面。
我試着做ContactForm.objects.all()
但我得到的錯誤是:Objects attribute does not exist for ContactForm
。
你可以叫objects.all()的模型,而不是形式。你可以添加模型代碼到你的問題嗎? –