我嘗試使用django視圖保存數據庫上的數據,但它返回一個錯誤。如何使用django視圖將數據保存在數據庫中?
def get_enroll(request, pk):
\t user = request.user
\t users = User.objects.filter(username=user)
\t course = Course.objects.filter(pk=pk)
\t chapter = ChapterModel.objects.filter(course = course)
\t abc = Enroll()
\t abc.save_enroll(users, course, chapter)
\t template_name = 'dashboard.html'
\t context = {'users':user,'course':course}
\t return render(request, template_name, context)
有什麼錯誤。請在問題 –