0
저는 데이터로 dicts의 dict을 만들고 템플릿에 전달하려고합니다.dicts django의 dict에 쿼리 세트를 변환합니다.
Exception Value:
'QuerySet' object does not support item assignment
내가 장고와 프로그래밍 그래서이 하자구 취할 새로운 오전 :
models.py
class Lesson(models.Model):
...
class Files(models.Model):
...
class Section(models.Model):
file = models.ManyToManyField(Files)
lesson = models.ForeignKey(Lesson)
views.py
def LessonView(request):
the_data={}
all_lessons= Lesson.objects.all()
for lesson in all_lessons:
the_data[lesson]=lesson.section_set.all()
for section in the_data[lesson]:
the_data[lesson][section]=section.file.all() <---error
Context={
'the_data':the_data,
}
return render(request, 'TMS/lessons.html', Context)
는 오류가 발생합니다 템플릿에 각 강의의 각 섹션에 대한 파일 목록을 표시 할 수 있도록 데이터를 전달하는 올바른 방법은 무엇입니까?
감사합니다. 쿼리는보기에서 수행해야합니다. – belonious