0
from django.views import generic
from .models import Inspectionfile
from .models import posts
class IndexView(generic.ListView):
template_name = "posts/index.html"
def get_queryset(self):
return Inspectionfile.objects.all()
class DetailView(generic.DetailView):
model = Inspectionfile
template_name = "posts/detail.html "
#index template
<ul>
{% for o in object_list %}
<li><a href = "/posts/{{o.id}}/">{{o.document_title}} </a> </li>
{% endfor %}
</ul>
#detail template
<h1>{{ o.document_title }}</h1>
내 인덱스 템플릿이 작동하지만 세부 템플릿이 값을 가져 오지 않는 것처럼 보이기 때문에 공백으로 표시됩니다. 그래서 'o'는 세부 사항에 전달되지 않습니까 ?? 나는 이것을 풀 수 없었다. BTW document_title은 내 inspectionfile 모델의 필드 중 하나입니다. 내 URL 정규식을 확인하고 잘 작동하는 것 같습니다.Django의 세부 템플릿이 값을 가져 오지 않음
그건 내 첫 번째 생각 이었어 !! 그런데 어떤 사람들은 이런 식으로 일하는 것을 보았습니다. 그들은 세계적인 대상이 있어야합니다. 어쨌든 매력처럼 일했습니다 !! 정말 고맙습니다!! –