0
如何將對象從ClassDetail傳遞給CreateNewStudent以便在其模板中使用它?如何將多個對象放在一個模板中
感謝。
class ClassDetail(DetailView):
context_object_name = "Class"
template_name = "temp/students.html"
model = Class
class CreateNewStudent(CreateView):
model = Student
form_class = forms.StudentForm
template_name = "temp/newstudent.html"
我確實需要使用CBV,是否有任何其他方式與CBV做到這一點? – Goun2
感謝您的回答 – Goun2
根據官方文檔「顯示用於創建對象的表單的視圖,重新顯示帶有驗證錯誤(如果有)的表單並保存該對象」。所以不行 –